save .msg as rtf and how to open a msg file

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

1) I want to save a current open email that has an
attachment as a .rtf including the attachment.

If I run the below code from an outlook module it works,
if I run it from a module in Xl or Word the attachment in
the mail is not saved.

Any clue what I'm doing wrong?

Sub SAVEFILE()
Set myolapp = CreateObject("Outlook.Application")
Set myItem = myolapp.ActiveInspector
If Not TypeName(myItem) = "Nothing" Then
Set objItem = myItem.CurrentItem
'strname = objItem.Subject
objItem.SaveAs "C:\test.rtf", olRTF
Else
MsgBox "There is no current active Inspector."
End If

End Sub


2) How can you open a .msg file in outlook saved on HD
e.g. c:\test.msg through vba (preferably outlook vba)?
 
1. Saving in the RTF format only saves the message body, but not the
attachments.
2. Use Namespace.CreateItemFromTemplate

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Thanks Dmitry.
1) I fogot to reference outlook in excel.
objItem.SaveAs "C:\test.rtf", olRTF does save the the
messaage body and the attachment if there is one present
now.

2) Namespace.CreateItemFromTemplate -
That helps eventhough the mail is opened in reply mode.

I finally used:
Shell "Outlook.exe /f c:\test.msg"

Paul
 
Back
Top