Open an attachement of type olEmbeddeditem

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
 
D

Dmitry Streblechenko

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
 
N

Nuno

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
 
D

Dmitry Streblechenko

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top