Search code examples
ewsjavaapi

how can I set DateTimeReceived on an EmailMessage?


I need to (directly or indirectly) set the DateTimeReceived on an EmailMessage, so I can call emailMessage.save()

I dug into the source (EmailMessage, Item, PropertyBag, ItemSchema) but I didn't see a way to set the Received header (couldn't find any way to directly access headers) nor a way to set ItemSchema.DateTimeReceived (it's marked read-only). Is there anything I missed?


Solution

  • I got advice in an email thread. In case it helps anyone else, you can set properties like DateTimeReceived as a new ExtendedPropertyDefinition(0x0E06, MapiPropertyType.SystemTime).

    (However, being new to this API, I haven't yet figured out where the reference is for all the possible "extended property definition" values that EWS understands.)