2

I write client application that uses Exchange Web Services Proxy Classes in order to connect to Exchange Web Services. Sometimes, I need create ItemType object and make it looks like as received letter. Therefore I need set up such properties of ItemType as DateTimeSent, DateTimeCreate, DateTimeReceived, but they haven’t public set assessTherefore I need set up such properties of ItemType as DateTimeSent, DateTimeCreate, DateTimeReceived, but they haven’t public set assessor.

I found resolve for some of them via MAPI properties:

ItemType newItem = xmlParser.LoadItem(); //info for newItem takes from xml
    newItem.ExtendedProperty = new ExtendedPropertyType[1];
    PathToExtendedFieldType q = new PathToExtendedFieldType();
    q.PropertyTag = "3590"; //DeliveryTime
    q.PropertyType = MapiPropertyTypeType.SystemTime;
    newItem.ExtendedProperty[0] = new ExtendedPropertyType();
    newItem.ExtendedProperty[0].ExtendedFieldURI = q;
    newItem.ExtendedProperty[0].Item = new System.DateTime(2014, 5, 5, 5, 5, 5).ToString("yyyy-MM-ddTHH:mm:ssZ");

Well, it works for DateTimeSent and DateTimeReceived, but not for DateTimeCreate. ES dont give any errors, but DateTimeCreate doesnt change. I tried to UpdateItem with DateTimeCreate propery, but there was no result (update another properties runs fine).

P.S. MAPI ID for CreationTime: 0x3007.

Can someone help me with this problem?

IStar
  • 184
  • 1
  • 15

2 Answers2

3

I finally found a solution for this.

Source: https://social.msdn.microsoft.com/Forums/en-US/40a29c69-96d3-488b-8f0e-911dd5f04086/setting-a-emailmessage-datetimesent-and-isdraft?forum=exchangesvrdevelopment

You have to set 3 Extended MAPI properties PR_MESSAGE_FLAGS, PR_MESSAGE_DELIVERY_TIME, and PR_CLIENT_SUBMIT_TIME. Make sure when setting the Time you use UTC time.

For example:

        EmailMessage emUploadEmail = new EmailMessage(service);
        emUploadEmail.MimeContent = new MimeContent("us-ascii", bdBinaryData1);
        //  PR_CLIENT_SUBMIT_TIME
        emUploadEmail.SetExtendedProperty(new ExtendedPropertyDefinition(57,MapiPropertyType.SystemTime), DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
        // PR_MESSAGE_DELIVERY_TIME 
        emUploadEmail.SetExtendedProperty(new ExtendedPropertyDefinition(3590, MapiPropertyType.SystemTime), DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
        //  PR_MESSAGE_FLAGS
        emUploadEmail.SetExtendedProperty(new ExtendedPropertyDefinition(3591,MapiPropertyType.Integer),"1");
        emUploadEmail.Save(WellKnownFolderName.Inbox);
LR2
  • 61
  • 3
  • You're welcome, glad I could help! This one had me scratching my head for a long while! – LR2 Nov 05 '17 at 20:40
2

Create and last modified dates are read-only and cannot be set. The store provider updates these properties internally.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • DateTimeSent and DateTimeReceived are read-only properties too. But there are lof of softs, that can setup and change CreationTime (OutlookSpy, for example). And i found "resolve" for EWS Managed API: [link](http://ireznykov.wordpress.com/2013/03/09/set-property-of-emailmessage-in-ews/). But i can't make it works. Well, i think there must be a resolve.... – IStar May 31 '13 at 06:17
  • No store provider that I know of will let you change created and last modified dates. OutlookSpy (which I wrote) has no magic wand. Sent and Received dates can be changed just fine using MAPI or Redemption, it is just that the Outlook Object Model provides a read-only access only. – Dmitry Streblechenko May 31 '13 at 16:57