我尝试使用 EWS Java API 在电子邮件中发送“字符串”内容:
<root>
<tag1>text1</tag1>
<tag2>text2</tag2>
</root>
我使用的代码是:
String msg = content given above;
ExchangeService service = new ExchangeService();
ExchangeCredentials credentials = new WebCredentials(user, password);
service.setCredentials(credentials);
try {
service.setUrl(new java.net.URI(exchangeURL));
service.setTraceEnabled(true);
EmailMessage message = new EmailMessage(service);
message.setSubject(mail_sub);
message.setFrom(fromaddress);
message.setBody(new MessageBody(msg));
message.getToRecipients().add("emailaddress");
message.send();
}
但我收到的电子邮件内容为:
文字 1 文字 2
我该如何解决这个问题?我正在使用 Exchange 2010 和 EWS Java API 1.2。