0
votes

my C# program is creating a EmailMessage item via Exchange Web Services (EWS 2.2.0) on Exchange 2010 SP2. When I call the Save method, it shows up in the Outlook drafts folder but has DateTimeSent set to current time.

This seems incorrect to me because when I create and save an email as a draft using Outlook, the property is null. The property is also readonly so I can't set it to null.

I've tried to set it with SetExtendedProperty but did not succeed.

Any ideas how to prevent this? My users complain that the "Sent Date" shows up in printed email drafts (yes I know...) which aren't sent yet.

Cheers

1

1 Answers

0
votes

I found a workaround that works for my case. If i set the extended property PR_CLIENT_SUBMIT_TIME to 1st Jan of 5000 it is not shown in Outlook nor on the printout:

var msg=new EmailMessage();
const int PR_CLIENT_SUBMIT_TIME = 0x0039;
DateTime weirdDateThatSomeHowIsIgnoredByExchange = new DateTime(5000, 1, 1);
msg.SetExtendedProperty(
    new ExtendedPropertyDefinition(PR_CLIENT_SUBMIT_TIME, MapiPropertyType.SystemTime),
    weirdDateThatSomeHowIsIgnoredByExchange.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
msg.Save(folder.Id);