Automation 如何使用JAVA在一个会话中发送多封电子邮件
我有一个XML,通过在excel中传递它,我用XML模拟了测试数据,我得到了多个模拟字符串格式的文件,并将其作为字符串发送到队列 这是存储在outputXMLString中的字符串格式的模拟文件。这适用于单个文件,但在发送多个模拟文件时,它会使用最新的文件。 String outputXMLString=writer.getBuffer().toString()Automation 如何使用JAVA在一个会话中发送多封电子邮件,automation,xml-parsing,jakarta-mail,stringwriter,filestreamresult,Automation,Xml Parsing,Jakarta Mail,Stringwriter,Filestreamresult,我有一个XML,通过在excel中传递它,我用XML模拟了测试数据,我得到了多个模拟字符串格式的文件,并将其作为字符串发送到队列 这是存储在outputXMLString中的字符串格式的模拟文件。这适用于单个文件,但在发送多个模拟文件时,它会使用最新的文件。 String outputXMLString=writer.getBuffer().toString() 如果你想发送多个文件,你不希望在某个地方有一个循环吗。。循环是为了迭代而添加的…通过编码完成,工作正常。谢谢 Tran
如果你想发送多个文件,你不希望在某个地方有一个循环吗。。循环是为了迭代而添加的…通过编码完成,工作正常。谢谢
Transformer tf = TransformerFactory.newInstance().newTransformer();
tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
tf.setOutputProperty(OutputKeys.INDENT, "yes");
tf.setOutputProperty(OutputKeys.METHOD, "xml");
tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
StringWriter writer = new StringWriter();
tf.transform(new DOMSource(doc), new StreamResult(writer));
String outputXMLString = writer.getBuffer().toString();
System.out.println("----- Sendingtext:--- " + "\n" + outputXMLString);
return outputXMLString;