none
How can I save mail body as RTF with inline images? RRS feed

  • Question

  • Hi

    I've tried using ...

    MailItem.SaveAs("c:\test.rtf", Outlook.OlSaveAsType.olRTF)

    But that will include stuff like From, Sent, To etc.

    How can I save the mail BODY only (with inline images) as RTF?

    Thanks :)




    • Edited by M O J O Tuesday, January 13, 2015 10:53 AM
    Tuesday, January 13, 2015 10:53 AM

Answers

  • Hello MOJO,

    Outlook uses Word as an email editor. You can use the Word object model to save the body only. The WordEditor property of the Inspector class returns an instance of the Document class which represents the body. See Chapter 17: Working with Item Bodies for more information.

    • Marked as answer by M O J O Tuesday, January 13, 2015 11:33 AM
    Tuesday, January 13, 2015 11:08 AM
  • Hi MOJO,

    Thanks for sharing the solutlion with us.

    We also could use MailItem.RTFBody to get the RTF format of mail body. And here is a sample for your reference:

    Sub GetRTFBodyForMail() 
     
     Dim oMail As Outlook.MailItem 
     
     Dim strRTF As String 
     
     If Application.ActiveInspector.CurrentItem.Class = olMail Then 
     
     Set oMail = Application.ActiveInspector.CurrentItem 
     
     strRTF = StrConv(oMail.RTFBody, vbUnicode) 
     
     Debug.Print strRTF 
     
     End If 
     
    End Sub 
    
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 14, 2015 2:16 AM
    Moderator

All replies

  • Hello MOJO,

    Outlook uses Word as an email editor. You can use the Word object model to save the body only. The WordEditor property of the Inspector class returns an instance of the Document class which represents the body. See Chapter 17: Working with Item Bodies for more information.

    • Marked as answer by M O J O Tuesday, January 13, 2015 11:33 AM
    Tuesday, January 13, 2015 11:08 AM
  • Hello MOJO,

    Outlook uses Word as an email editor. You can use the Word object model to save the body only. The WordEditor property of the Inspector class returns an instance of the Document class which represents the body. See Chapter 17: Working with Item Bodies for more information.

    Great thanks! 

    My solution was...

    Dim inspector As Outlook.Inspector = Globals.ThisAddIn.Application.ActiveInspector
    Dim doc As Microsoft.Office.Interop.Word.Document = CType(inspector.WordEditor, Microsoft.Office.Interop.Word.Document)
    doc.SaveAs2("c:\test.rtf", FileFormat:=6)

    Tuesday, January 13, 2015 11:34 AM
  • Hi MOJO,

    Thanks for sharing the solutlion with us.

    We also could use MailItem.RTFBody to get the RTF format of mail body. And here is a sample for your reference:

    Sub GetRTFBodyForMail() 
     
     Dim oMail As Outlook.MailItem 
     
     Dim strRTF As String 
     
     If Application.ActiveInspector.CurrentItem.Class = olMail Then 
     
     Set oMail = Application.ActiveInspector.CurrentItem 
     
     strRTF = StrConv(oMail.RTFBody, vbUnicode) 
     
     Debug.Print strRTF 
     
     End If 
     
    End Sub 
    
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 14, 2015 2:16 AM
    Moderator