I'm writing an Outlook COM addin using C++/ATL.
I'm getting a rather odd set of errors and results back from Outlook when I call _PostItem::SaveAs. This only occurs in Outlook 2002 (Outlook XP) and only when the _PostItem is an embedded item (an attachment of some other outlook item).
If the Post is an HTML type, it fails with E_INVALIDARG for olRTF. I'm OK with this as I then try another type, olHTML. This succeeds, but the resulting HTML file only contains the header information, no body. Same thing occurs with olTXT - no body.
If I attempt to save it as olMSG, I get back rather odd error codes. I reran the SaveAs a couple of times and received these codes:
0xd8b70005 0xdee70005 0xe5170005 0xeb470005
The common bits would appear to be 0x80070005 --> E_ACCESSDENIED. I know file permissions are OK, so I'm guessing something is wrong accessing the underlying MAPI object.
From a different post (has an attachment), I also received 0xcc540102 which, stripping the garbage from the upper bytes looks like 0x80040102.
I should mention that the _PostItem is being obtained in a odd fashion:
1) calling IMessage::OpenAttach(MAPI_BEST_ACCESS) against a normal MAPI Message object 2) calling OpenProperty() on that attachment object to get the embedded object's MAPI Message object 3) open a Form (DoVerb) and the form's CurrentItem is _PostItem that I need to use.
Am I missing permissions someplace on the MAPI message object?
Thanks for any help you can offer.
-Rohde