Sebastian Kirsche
Sebastian Kirsche

Reputation: 883

IMAPIProp::CopyTo returns MAPI_E_NO_ACCESS if IMessage is opened from .msg file

I use IMAPIProp::CopyTo in an add-in for Outlook 2010 to save the currently displayed IMessage into a new IMessage in a .msg file on disk. Everything works fine for messages that reside in the user's mailbox.

When I try this with messages that are opened from a .msg file on disk and contain attachments, IMAPIProp::CopyTo returns 0x80070005 (MAPI_E_NO_ACCESS). The details returned from IMAPIProp::GetLastError are:

ulVersion: 0
lpszError: "A resource is busy or you lack sufficient access rights or permissions"
lpszComponent: ""
ulLowLevelError: 71
ulContext: 0

After using File->Save As or File->Save, my call to IMAPIProp::CopyTo succeeds, too. IMAPIProp::CopyTo also succeeds if I exclude PR_MESSAGE_ATTACHMENTS.

What might Outlook be doing to prepare for a successful call to IMAPIProp::CopyTo?

Upvotes: 0

Views: 1766

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66316

CopyTo() does not work too well (if at all) with messages created on top of MSG files. Your only option is pretty much writing your own function that does GetPropList, then copies one property at a time (converting named properties appropriately of course), followed by copying the attachments and recipients.

Upvotes: 2

Related Questions