Search code examples
c#outlookrtf

Save Outlook mailitem body as PDF


I'm working with Outlook and C# and my school exercise is to convert the body of an email in pdf without using extra software. In my case I would like to keep the email text format so to solve my problem I've considered to convert the email body in a RTF file, then open this RTF file with the Word application by C# and save it as PDF.

I would like to know how to obtain a RTF file from an MailItem. I've found on the web that it is possible to convert the MailItem body in RTF format using the BodyFormat property but i don't get how to create then a RTF.


Solution

  • Should be as simple as:

    MailItem.BodyFormat = OlBodyFormat.olFormatRichText;
    MailItem.SaveAs("FilePath", OlSaveAsType.olRTF)
    

    MailItem.BodyFormat Property:

    http://msdn.microsoft.com/en-us/library/office/ff869979(v=office.15).aspx

    MailItem.SaveAs Method:

    http://msdn.microsoft.com/en-us/library/office/ff868727(v=office.15).aspx