简体   繁体   中英

Unable to SaveAs MailItem as msg file using third party application

I have vsto Addon for outlook. In my addon, there is a functionality to save mail items locally. This functionality is worked in the background automatically. To implement this functionality, I have developed one background application. In this application, I will save the email in a decided folder. This add-on works fine for my computer but in some of client-facing an issue while saving email. As per the log files, I have checked when I tried to save email this error is generated.

Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))

Before publishing this blog, I have tried to get a fresh mail item using Outlook. Application object but still the issue is not fixed.

Can anyone please help us to solve this issue?

Thanks

Outlook Object Model cannot be used from a secondary thread in the outlook.exe process address space. You can use it from a secondary thread in an external process, but then the call will be marshaled to the main Outlook thread anyway. There is no marshaling in-proc, hence you get an error.

Your options are Extended MAPI (C++ or Delphi only) or Redemption (can be used in any language). In the latter case, you can save the value of the Namespace.MAPIOBJECT and MailItem.EntryID properties in separate variables on the main thread, and on the secondary thread create an instance of the RDOSession object, set its MAPIOBJECT property to the value saved on the main thread, open then message using RDOSession.GetMessageFromID , then call RDOMail . SaveAs(..., olMsg) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM