I followed this link to generate the jar file. I added this to my project. Then have a simple code to send a mail:
public void mailSend() {
ExchangeService service = new ExchangeService();
ExchangeCredentials credentials = new WebCredentials(
"email", "$*pass!");
service.setCredentials(credentials);
String host = "host";
try {
service.setUrl(new java.net.URI("https://" + host
+ "/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();
Log.i("Msg","SEND ");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
The problem is that it shows the jar file has no source attachment. Hence I get the error no definition found for class ExchangeService
. This should be part of the jar file generated. While exporting as jar file, I had made sure the src folder is clicked.