none
Setting a EmailMessage DateTimeSent and IsDraft RRS feed

  • General discussion

  • I would like to save email messages to a folder as if they had been sent.  I want to set the DateTimeSent and the IsDraft (to false) but they are read only in EWS Managed API 1.0.  Is there any chance that it will be opened up (set to go with the get)?  Do I have to use extended properties?

    Thanks
    Thursday, December 3, 2009 9:39 PM

All replies

  • You have to set 3 Extended MAPI properties PR_MESSAGE_FLAGS http://msdn.microsoft.com/en-us/library/cc839733.aspx, PR_MESSAGE_DELIVERY_TIME http://msdn.microsoft.com/en-us/library/cc841961.aspx  and PR_CLIENT_SUBMIT_TIME http://msdn.microsoft.com/en-us/library/cc839781.aspx . Make sure when setting the Time you use UTC time


    eg

                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);
    Cheers
    Glen
    Friday, December 4, 2009 8:41 AM