Search code examples
c#c#-4.0outlook-addinoutlook-2010

Close draft mail without saving in Outlook using C#


When I try to close a draft mail in outlook it asks a message box to save, discard or cancel. I want to write the code to automatically discard it without prompting that message.

If I use mailItem.Save(); . That message box will not appear. But it saves the message in the folder what I didn't want.


Solution

  • So in order to make it as an answer for other people to see it - maybe what you need to do is the following:

    1. Save the item.
    2. Close the composer.
    3. Delete the item.

    This way you will not have the item in any of the folders and you will still have avoided the save prompt?

    So just call Item.Delete(); after you close the composer.

    Hope this helps.