Home > Net >  How can one prevent an Outlook MailItem unsaved draft from being saved when a property is added to t
How can one prevent an Outlook MailItem unsaved draft from being saved when a property is added to t

Time:03-22

When one begins composing an email in Outlook it exists as an "unsaved draft". If you close the email you are prompted to save/discard the draft. Until one saves the draft the email does not exist in one's draft items folder.

I need to add a property to an unsaved draft MailItem and for the MailItem to remain in an unsaved draft state. Unfortunately, using MailItem.Save results in the MailItem becoming a saved draft.

Is there a way to either prevent the MailItem from being a saved draft or to revert it to an unsaved draft after the save?

CodePudding user response:

Trap the MailItem.Write event and set your custom property in the event handler. This way the property will only be set only before the message is saved.

CodePudding user response:

If you close the email you are prompted to save/discard the draft.

You can add your custom property and call the Save method to avoid such dialogs.

Otherwise, consider keeping any custom data out of the Outlook item. It can be a DB or any other storage where you can grab the data for a particular item.

  • Related