I tried to use the following code to send mail using EWS Java API. But I get the error that the NTLM Authentication is selected. I need only Basic Authentication. How do I specify the authentication type.
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();
}
Please tell me how to solve this....:(