export selected mail message to .msg file

V

Vinayakc

Hi,

I am begginer in Outlook COM Add-in dev. I am developing one
application using ATL COM, VC++.

I want to achieve following functionality.

When user clicks on Add-in button then application should create one
new mail message and selected mail will be attached to that new mail as
..msg file. This new mail then will be forwarded to one hardcode email
address.
I have completed some part from functionality mention above, Only
remaing thing is how can i export selected mail to .msg file and how
can I attach this .msg file to my new message.

Please help me. Thanks in advance.

Regards
Vinayakc
 
D

Dmitry Streblechenko

Calling MailItem.Attachments.Add(AnotherMailItem) would create an embedded
message attachment
If you want an MSG file, call MailItem.SaveAs(filename, olMsg)

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

Vinayakc

Hi Dmitry,

Thank you very much. But I did not get "Attachments" property for mail
item.
I think VC++ did not have this property for mail item.
I declared mail item like

CComPtr<Outlook::_MailItem> spMailItem;

Can you please help me again.

regards
Vinayak
 
D

Dmitry Streblechenko

MailItem does have the Attachments property which returns an instance of the
Outlook.Attachments object.
Depending on how you created the wrappers, the method could be called
something like get_Attachments().

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

Vinayakc

Hi Dmitry,
Thanx. I got the solution.
I have tried following code and it works.


CComPtr<Outlook::Attachments>pAttachments;
CComPtr<Outlook::Attachment> pAttachment;

CComPtr<Outlook::_MailItem> spMailItem;

pMailItem->get_Attachments(&pAttachments);
pAttachments->Add(
CComVariant(spMailItem), //Source
CComVariant(Outlook::blush:lByValue), // Type
CComVariant(1), // Position
CComVariant(""), // DisplayName
&pAttachment
);

Thanks a lot for your valuable support.

Regards
Vinayakc
 

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