locked
Convert MSG To PDF

    General discussion

  •  

    Hello,

    I need to convert MSG files to PDF through an automation process.

    I first thought of opening the email in Outlook and saving it as a
    MSG file and then to convert the file to PDF

    I've also been looking at Outlook's SaveAs method but the warning
    message that pops up requires user intervention and that's no good for
    my solution.

    Please help me.

    Regards,


    http://www.alhambra-eidos.es/web2005/index.html
    Thursday, December 11, 2008 12:04 PM

All replies

  • Hi Alhambra,

    There isn't one current library to implement this requirement.

    If you use the Office2007, you can use Outlook Automation to save the email to Html document. Then automate Word application to open this Html, then save as the PDF document.

    If you use the previous edition, you can read this article for your reference. You need to use 3-rd tool or Office automation to implement your requirement.

    Riquel

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.





    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, December 15, 2008 3:25 AM
  • Thanks,

    any sample code for:

    1. Outlook Automation to save the email to Html document

    2. Automate Word application to open this Html, then save as the PDF document.

    Thanks in advanced !!! Greetings

    http://www.alhambra-eidos.es/web2005/index.html
    Monday, December 15, 2008 7:49 AM
  • 1.  Outlook has no method to do that. You can do it, however, with Redemption. See http://www.outlookcode.com/codedetail.aspx?id=716 for your reference.

    2. Record Macro in Word to know how to automate the Word to implement this.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Proposed as answer by Amrykid Wednesday, December 17, 2008 4:05 PM
    Wednesday, December 17, 2008 10:15 AM
  • if you want to convert stuff to pdf, search google for iTextSharp.
    • Proposed as answer by Amrykid Wednesday, December 17, 2008 4:05 PM
    Wednesday, December 17, 2008 4:05 PM
  • The best option for converting MSG files to PDF is to use Neevia Document Converter Pro . All you have to do is install it on your machine then submit the msg files to the input folder watched by the converter. It comes with an ActiveX interface in case you need to do it programmatically. Code sample on how to submit a file via code are on their website.

    Thursday, May 13, 2010 7:41 PM
  • I use Total Mail Converter to convert msg to pdf. Few weeks ago I had to convert all old email to pdf to archiving; tried several converters. This one did the job perfectly and placed all attachments into separate folders. They say it has command line support, though I didn't use it.

    http://www.coolutils.com/TotalMailConverter

     

     

     

    Monday, July 12, 2010 8:47 AM
  • Few days back i am also searching for a tool to convert msg file to pdf..

     

    Now i get it from Birdie Software..you can also try it..its really helps you to convert the MSG file to PDF..

    Get the Birdie MSG to PDF Converter...

    get the software from http://www.birdiesoftware.com/eml-to-doc/buy.html....

    thnx to Birdie Software

    gud luck guys......... :)

     

    Thursday, July 15, 2010 9:36 AM
  • Hello,

    A great tool for converting MSG and EML files to PDF is Email Open View Pro.  Not only can you convert MSG files to PDF, you can also extract and convert emails from PST files too! And, you don't even have to have Outlook installed to do it.

    You can check it out at:

    http://bitdaddys.com/emlopenviewpro.html

    Be sure to check out the command line options for email to pdf conversion.

     

    Sunday, September 19, 2010 12:39 PM
  • Alhambra Eidos Desarrollo Users MedalsUsers Medals,

     

    You can convert a physically stored (ie, stored in your hard disk) .msg file to pdf by the fillowing code

     

     public void ConvertMsg(FileInfo MsgFiles)
        {

            Microsoft.Office.Interop.Outlook._Application oApp =new Microsoft.Office.Interop.Outlook.Application();;

            Microsoft.Office.Interop.Outlook.NameSpace name = oApp.GetNamespace("MAPI");
            String SourceFileName = MsgFiles.FullName;
            String OutPutFileName = MsgFiles.FullName.Replace(MsgFiles.FullName.Substring(MsgFiles.FullName.LastIndexOf("."), (MsgFiles.FullName.Length - (MsgFiles.FullName.LastIndexOf(".")))), ".doc");
            Microsoft.Office.Interop.Outlook.MailItem message = null;
            message=(MailItem) name.OpenSharedItem(SourceFileName);
            try
            {
              
                if (message != null)
                {
                    message.SaveAs(OutPutFileName, OlSaveAsType.olDoc);
                    DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath("Files"));
                    FileInfo[] ExportFiles = dirInfo.GetFiles();
                    foreach (FileInfo file in ExportFiles)
                    {
                        if (file.FullName == OutPutFileName)
                        {
                            ConvertDOCFiles(file);
                            if (File.Exists(file.FullName))
                            {
                                file.Delete();
                            }
                        }
                    }

                }
            }

            catch (System.Exception ex)
            {

            }
            finally
            {
                message.Close(OlInspectorClose.olDiscard);
                message = null;
                //oApp.Quit();
                //oApp = null;
                GC.Collect();
            }
            


        }

     

    public void ConvertDOCFiles(FileInfo wordFile)
        {
            Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
            // Cast as Object for word Open method
            Object filename = (Object)wordFile.FullName;

            // Use the dummy value as a placeholder for optional arguments
            Document doc = word.Documents.Open(ref filename, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing);
            doc.Activate();

            object outputFileName = wordFile.FullName.Replace(wordFile.FullName.Substring(wordFile.FullName.LastIndexOf("."), (wordFile.FullName.Length - (wordFile.FullName.LastIndexOf(".")))), ".pdf");
            object fileFormat = WdSaveFormat.wdFormatPDF;

            // Save document into PDF Format
            doc.SaveAs(ref outputFileName,
                ref fileFormat, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing);

            // Close the Word document, but leave the Word application open.
            // doc has to be cast to type _Document so that it will find the
            // correct Close method.               
            object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
            ((_Document)doc).Close(ref saveChanges, ref oMissing, ref oMissing);
            doc = null;
            // word has to be cast to type _Application so that it will find
            // the correct Quit method.
            ((Microsoft.Office.Interop.Word.Application)word).Quit(ref oMissing, ref oMissing, ref oMissing);

            word = null;
        }



    George Mathew
    Tuesday, May 03, 2011 8:35 AM
  • Hello,

    I used an application to do it for me.  It lets you convert Msg files into PDF and other format.

    Kindly check the link below.

    http://www.pstviewerpro.com/2012/08/msg-to-pdf-converter.html

    Hope this helps

    Tuesday, August 14, 2012 6:38 PM