我正在尝试使用 EWS Java API for android app 连接到 Exchange Server 2010,但在使用 EWS API 时出现错误:
例外:
找不到方法 javax.xml.stream.XMLOutputFactory.newInstance,引用自方法 microsoft.exchange.webservices.data.EwsUtilities.formatLogMessage
VFY: 无法解析静态方法 6011: Ljavax/xml/stream/XMLOutputFactory;.newInstance ()Ljavax/xml/stream/XMLOutputFactory; 找不到方法 javax.xml.stream.XMLStreamWriter.writeStartElement,引用自方法 microsoft.exchange.webservices.data.EwsUtilities.writeTraceStartElement
错误:
致命例外:主要的 12-26 14:20:10.384:
java.lang.VerifyError: microsoft/exchange/webservices/data/EwsServiceXmlWriter at microsoft.exchange.webservices.data.ServiceRequestBase.emit(Unknown Source) at microsoft.exchange.webservices .data.MultiResponseServiceRequest.execute(未知来源)
我发送邮件的源代码是:
ExchangeService service = new ExchangeService();
ExchangeCredentials credentials = new WebCredentials("username", "password");
service.setCredentials(credentials);
try {
uri = new URI("https://host name/ews/Exchange.asmx");
} catch (URISyntaxException e) {
e.printStackTrace();
}
service.setUrl(uri);
try {
EmailMessage msg= new EmailMessage(service);
msg.setSubject("Heloo World ");
msg.setBody(MessageBody.getMessageBodyFromText("Send using ews api in android "));
msg.getToRecipients().add("email address");
msg.send();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
提前致谢。