Open an attachement of type olEmbeddeditem

  • Thread starter Thread starter Nuno
  • Start date Start date
N

Nuno

Hello!

I hant to now wich is the best way to get a _MailItem from an
attachment that is of the type olEmbeddeditem?

It's necessary to save it to disk and open like a mail item? if is how
this is done? or we can do something like this:

....
AttachmentPtr att = attac->Item(l);
_MailItemPtr pMailSubItem;
hr = att->QueryInterface(__uuidof(_MailItem),(void**)&pMailSubItem);

This way does not work, it gives E_NOINTERFACE


What's the best way to do it?

Thanks
Nuno
 
The best you can do in Outlook Object Model is to save the attachment as an
MSG file, then open it using the Shell API to make Outlook display it.
In Extended MAPI you will need to open the PR_ATTACH_DATA_OBJ property
(IAttach::OpenProperty) as IMessage
You can use Redemption (url below) to access the embedded message using
Attachment.EmbeddedMsg

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Thanks for the response i already handle the problem... is like you
said, i save the attach as a msg file and then i open it.

Here's some example code:

AttachmentPtr att = attac->Item(l);
hr=piAtt->SaveAsFile(_bstr_t(strFile));
_MailItemPtr pMailSubItem =
att->GetApplication()->CreateItemFromTemplate(_bstr_t(strFile));
if(pMailSubItem)
{
//do something with it
}

But thanks anyway...

Nuno
 
Just keep in mind that CreateItemFromTemplate(0 does not preserve sender and
receiver properties...

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Back
Top