EmailMessage message = new EmailMessage(service);
MessageBody body= new MessageBody("Hi This is the test mail.");
EmailAddress toEmail = new EmailAddress("kishore.kolli@hma.com");
EmailAddress fromEmail = new EmailAddress("cms.899@hma.com");
message.forward(body, toEmail);
The above code throwing the exception
Exception in thread "main" microsoft.exchange.webservices.data.InvalidOperationException: This operation can't be performed because this service object doesn't have an Id.at microsoft.exchange.webservices.data.ServiceObject.throwIfThisIsNew(Unknown Source)
at microsoft.exchange.webservices.data.Item.internalLoad(Unknown Source)
at microsoft.exchange.webservices.data.ServiceObject.load(Unknown Source)
at com.hma.util.mailclient.exchange.ExchangeMailClient.sendMails(ExchangeMailClient.java:119)
at com.hma.util.mailclient.exchange.ExchangeMailClient.main(ExchangeMailClient.java:150)