Setting the date on migrated email messages with Exchange Web Services

After much failed effort on my part, Matt Stehle at Microsoft graciously provided me the following function to set the PidTagMessageDeliveryTime on a mail item. Thank you, Matt!

public static void SetReceivedDate(ExchangeService service, ItemId itemId, DateTime date)
{
Item item = Item.Bind(service, itemId, new PropertySet(BasePropertySet.IdOnly));

item.SetExtendedProperty(new ExtendedPropertyDefinition(0x0E06, MapiPropertyType.SystemTime), date);

item.Update(ConflictResolutionMode.AutoResolve);
}

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s