export selected mail message to .msg file

  • Thread starter Thread starter Vinayakc
  • Start date Start date
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
 
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
 
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
 
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
 
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::olByValue), // Type
CComVariant(1), // Position
CComVariant(""), // DisplayName
&pAttachment
);

Thanks a lot for your valuable support.

Regards
Vinayakc
 
Back
Top