Wolfgang Denz
Posts: 18
Joined: 2011-08-05
|
Hi,
I have a problem when parsing the attachments of an email-message with my plugin.
When the attachment of a mail is a mail itself (*.msg) I want to save the attched email in RTF-format.
the things I already tried are the following:
// attached file is of format '.msg'
saveasType := olRTF;
attachmentFilename:= ChangeFileExt(attachmentFilename,'.RTF');
// first ettempt
iAttachment.QueryInterface(IID__MailItem, attachedMail);
attachedMail.SaveAs(attachmentFilename,saveAsType);
// second attempt
// attachedMail := GetMailItem(iAttachment as _Mailitem);
// (IAttachment as _Mailitem).SaveAs(attachmentFileName,saveAsType);
attachedMail := nil;
Both methods give an exception.
Can you give me a hint how to do that?
Thanks from germany
Wolfgang |
|
Andrei Smolin
Add-in Express team
Posts: 18821
Joined: 2006-05-11
|
Hello Wolfgang,
Here's what Ken Slovak - an Outlook development guru - wrote about this at http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/0f029f31-9005-4763-ae31-9b52f51ef7dd/:
If an attachment is an Outlook item then you can use the SaveAsFile() method with the attachment and save it as a MSG file. Use a file path in a temporary folder and give the attachment a name or use the DisplayName property, then use a "MSG" extension.
Once the file is saved out you can then open it as an Outlook item using Application.CreateItemFromTemplate() using the file path you just created. Then save the item (it will be created and saved in the default folder for that type of item). Then you can leave it there or copy it or move it elsewhere if desired.
Please find more details and useful code fragments (C#) in that thread. Feel free to ask me if you have other questions.
Andrei Smolin
Add-in Express Team Leader |
|
Wolfgang Denz
Posts: 18
Joined: 2011-08-05
|
Works perfect, thanks Andrei
Best regards
Wolfgang
PS: The support of AddinExpress ist really premium |
|