Search code examples
node.jsemailoutlookoffice365apioffice365-restapi

Check if a Message in the SentItems Folder had a Draft Counterpart Before being Sent


When a user is drafting an email, it shows up in the Drafts folder until it is sent. Once it is sent, it is removed from the Drafts folder and inserted into the SentItems folder, but as an entirely new object; many of its attributes are initialized to different values than when it was a draft, including its Id.

This makes it very difficult to accurately tell when a draft actually gets sent: because I cannot compare the Ids of the sent messages with the draft messages, I have resorted to comparing the recipients, the body, and the subject of the sent message with the draft message in an attempt to find the sent message's draft counterpart.

Hopefully there is a more straightforward method, thank you!


Solution

  • Traditionally the way to do this has been to add an app-defined custom property to the draft and set it to a unique value, then find the item in sent items that has that property value.