Sign In  Sign Up Live-Chat

email messages to PDF

Last post 07-16-2008, 8:22 AM by saqib.razzaq. 3 replies.
Sort Posts: Previous Next
  •  07-16-2008, 1:20 AM 135684

    email messages to PDF

    Please advise as of how can we use Aspose to print email (Outlook) messages (The main message, not the attachments).
    This message was posted using Page2Forum from Word to Pdf - Aspose.Pdf for .NET and Java
     
  •  07-16-2008, 1:22 AM 135685 in reply to 135684

    Re: email messages to PDF

    Correction: by "print" I meant "convert to PDF".
     
  •  07-16-2008, 1:45 AM 135690 in reply to 135685

    Re: email messages to PDF

    Dear Manuel,

    Aspose.Network deals with viewing and converting etc. Outlook email messages. That's why, i have moved your inquiry here so that Aspose.Network team can share their comments about it.

    Have a good time.


    Many Thanks & Kind Regards,

    Yours Truly,

    Salman Sarfraz
    Team Leader,
    Aspose Service Team
    Contact Us
    Aspose - The .NET and Java Component Publisher
     
  •  07-16-2008, 8:22 AM 135756 in reply to 135690

    Re: email messages to PDF

    Hi Manuel,

    There is no direct method of printing .msg file to pdf, but you can use the following code create a pdf document from the msg file. This code uses Aspose.Network and Aspose.Pdf libraries.

    You can modify the code to include other details if required.

    public string strOutlookFile = "c:\\outlook.msg";

    public string strPdfFile = "c:\\outlook.pdf";

    // load the message

    MailMessage mail = MailMessage.Load(strOutlookFile, MessageFormat.Msg);

    // create the header and body

    StringBuilder sb = new StringBuilder();

    sb.AppendLine("From:\t\t" + mail.From.ToString());

    sb.AppendLine("Sent:\t\t" + mail.Date.ToLongDateString() + " " + mail.Date.ToLongTimeString());

    sb.AppendLine("To:\t\t" + mail.To.ToString());

    if (mail.CC.Count >= 0)

    sb.AppendLine("Cc:\t\t" + mail.CC.ToString());

    sb.AppendLine("Subject:\t" + mail.Subject);

    sb.AppendLine(); sb.AppendLine(); sb.AppendLine(); sb.AppendLine();

    // create pdf doc

    Aspose.Pdf.Pdf pdf1 = new Aspose.Pdf.Pdf();

    Aspose.Pdf.Section sec1 = pdf1.Sections.Add();

    // create text paragraph

    Aspose.Pdf.Text text = new Aspose.Pdf.Text(sb.ToString() + mail.TextBody);

    // save pdf file

    sec1.Paragraphs.Add(text);

    pdf1.Save(strPdfFile);


    Best Regards,

    Saqib Razzaq
    Support Developer
    Aspose Guangzhou Team

     
View as RSS news feed in XML