我尝试使用以下代码使用 EWS Java API 发送邮件。但我收到选择 NTLM 身份验证的错误。我只需要基本身份验证。如何指定身份验证类型。
ExchangeCredentials credentials = new WebCredentials("user", "pwd");
service.setCredentials(credentials);
try {
service.setUrl(new java.net.URI("https://url/EWS/Exchange.asmx"));
service.setTraceEnabled(true);
EmailMessage msg = new EmailMessage(service);
msg.setSubject("Hello world!");
msg.setBody(MessageBody
.getMessageBodyFromText("Sent using the EWS Managed API."));
msg.getToRecipients().add("email");
msg.send();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
请告诉我如何解决这个问题.... :(