I'm trying to reply to email from java code, when I receive the reply, the Sent date is incorrect on the actual email. I think the Exchange service is considering UTC time.
Actual date Sent- Tue 1/3/2017 3:58 PM
Received date - Tuesday, January 3, 2017 8:58:51 PM
I don't know how to set the Exchange service time to consider Eastern time.
I'm able to get the server time zones by using
Collection<TimeZoneDefinition> response = service.getServerTimeZones();
But How to set the service to use only Eastern time.?
Here is my reply code.
PropertySet propertySet = new PropertySet(BasePropertySet.IdOnly,
EmailMessageSchema.From, EmailMessageSchema.CcRecipients,
EmailMessageSchema.Subject, EmailMessageSchema.Body,
EmailMessageSchema.Sender, EmailMessageSchema.DateTimeReceived,
EmailMessageSchema.Attachments);
propertySet.setRequestedBodyType(BodyType.HTML);
String itemId = emailMessage.getId().toString();
EmailMessage message = EmailMessage.bind(service, new ItemId(itemId), propertySet);
//message.getIsTimeZoneHeaderRequired(true);
//getESTTimeZone(service);
MessageBody errorMessage = new MessageBody();
errorMessage.setBodyType(BodyType.HTML);
errorMessage.setText(returnMessage);
message.reply(errorMessage, false); //false means do not reply all
I found a way around the problem, here's what I ended up doing. Hope it helps someone.