none
MailItem.save exception RRS feed

  • Question

  • Hi,

    I have issue when calling save method in MailItem object. Its throw 0x80004005 exception, "The operation failed.". I need to save this MailItem to continue. May I know what is the cause of the issue and how can I workaround with it.

    Below is the client details:

    Windows platform: windows 7 32-bit

    Outlook platform: Outlook 2010 32-bit (online mode)

    Mail server: Exchange server 2010


    Monday, October 1, 2018 6:12 AM

Answers

All replies

  • According to my research, I found the article mentioned, if a mail item is an inline reply, calling Save on that mail item may fail and result in unexpected behavior.

    Also, if not, you could refer to the following link:

    Outlook.MailItem.SaveAs() isn't work: "The operation failed"


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Monday, October 1, 2018 8:29 AM
  • You need to provide a lot more context than that.

    When exactly are you calling Save? How are you modifying the message? How do you opening it?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, October 1, 2018 6:41 PM
  • Thanks for the replies. We call Save in ItemEvent.Send event. Essentially, we have two MailItem objects. The outlook user is working on one MailItem object and the add-in is updating the other object. When user click send, the add-in will update the later MailItem and save it. This is when the exception occurs. Do note that this issue occurs intermittently.
    Monday, October 1, 2018 11:50 PM
  • How when do you open the problematic message? Where does it reside?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, October 2, 2018 1:13 AM
  • The message is used for saving purposes, never use to open. It is resided in user's Mailbox draft folder.
    Tuesday, October 2, 2018 2:20 AM
  • Firstly, if it sits in the Drafts folder, the user can see and modify it. Even if indirectly using the reading pane etc.

    Secondly, keeping a reference to any Outlook items for any prolonged periods of time is a bad idea - keep its entry id, when you need the message, open it using Namespace.GetItemFromID, make your changes, then immediately release it.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, October 2, 2018 3:51 AM
  • Thanks for your prompt reply. The item has not been save before (new item), thus will not have EntryID. What the add-in does is holding the object until the send event fired, and then perform the update and save.
    Tuesday, October 2, 2018 4:16 AM
  • Why not hold the data in an internal variable instead of a message and create/save that message when the Send event fires?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!


    Tuesday, October 2, 2018 5:33 AM
  • Thanks for the suggestion. I guess what I will do is to create a new item when send event fires.
    Tuesday, October 2, 2018 6:27 AM