Anderson Rissardi
Anderson Rissardi

Reputation: 2547

Save Outlook.MailItem Async?

Is there any way to save an Outlook.MailItem as a .msg file in an asynchronous way?

I'm using:

MailItem.SaveAs("path", Outlook.OlSaveAsType.olMSG);

But it's slow.

Upvotes: 2

Views: 283

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66286

Not using the Outlook Object Model - you cannot use a secondary thread inside the outlook.exe address space (COM addin): Outlook will raise an exception. If you do that from an external applications, all calls to OOM will be marshaled to the primary Outlook thread anyway.

Since you tagged your question as outlook-redemption, Redemption can do that - from your addin, store the value of the Application.Session.MAPIOBJECT in a variable as well as the MailItem.EntryID property. On the secondary thread, create an instance of the RDOSession object (that will initialize the MAPI system), set its MAPIOBJECT property to the value saved on the primary thread, call RDOSession.GetMessageFromID, then call RDOMail.SaveAs.

Upvotes: 3

Related Questions