Save .msg attachment as .rtf

  • Thread starter Thread starter hlock
  • Start date Start date
H

hlock

If an email has a .msg attachment, I need to save it off as an .rtf
attachment. Is there a way to do this?

If lngCount > 0 Then
' We need to use a count down loop for
' removing items from a collection. Otherwise,
' the loop counter gets confused and only every
' other item is removed.
For i = lngCount To 1 Step -1
Dim path As String
' Get the file name.
strfile = objAttachments.Item(i).FileName
'Check filename of attachment to see if .msg
If Right(strfile, 3) = "msg" Then
strfile = Replace(strfile, " ", "_")
strfile = strfile & ".rtf"
path = fso.BuildPath(tempdir, strfile)
objAttachments.Item.SaveAsFile path, olRTF
ExecCmd "ttimport.exe " & app & " " & strfile
Else
strfile = Replace(strfile, " ", "_")
'Combine with the path to the Temp folder.
strfile = tempdir & strfile
' Save the attachment as a file.
objAttachments.Item(i).SaveAsFile strfile
ExecCmd "ttimport.exe " & app & " " & strfile
End If
Next i
End If
Thanks!!
 
As far as I know Outlook can save only rtf formatted messages as rtf files.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Wed, 18 Nov 2009 09:31:03 -0800 schrieb hlock:
 
What about fooling it? Can we copy all of the aspects of the .msg (To, From,
CC, Subject, Body, etc) and create and .rtf. We are trying to avoid
importing .msg files into our document respository system since who knows
what email system we may be on later down the road. Any thoughts... If this
might work, how would I go about doing this?
 
Do you really mean embedded message attachments or regular attachments with
an .MSG extension?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
You can try to save the attachment as an MSG file and then import it back
using Application.CreateItemFromTemplate, butt that will wipe out teh sender
and recipeint related properties.
<plug>
You can use Redemption to open the MSG file directly using
RDOSession.GetMessageFromMsgFile, and then call RDOMail.SaveAs ..., olRtf
</plug>

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
RDOSession.GetMessageFromMsgFile, and then call RDOMail.SaveAs ..., olRtf

Would that preserve formattings of an html message?

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Wed, 18 Nov 2009 16:32:19 -0700 schrieb Dmitry Streblechenko:
 
That depends on whether the HTML is stored as RTF wrapped HTML in
PR_RTF_COMPRESSED.

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