12-08-24 06:13 PM
Hi Team,
I have a .msg file which i want to convert to .msg file. I have learned that in order to convert a .msg to .pdf, u need to
1. Open .msg into outlook & save as .html
2. Open .html from word & do save as pdf.
I am looking for an action or vbo code that can do Step #1. Has anyone used a similar functionality earlier ?
PS - My input is .msg. I dont have that email in outlook , so dont have its entry id. Please suggest a way with above mentioned approach or any other approach that does not require spying.
Your help is much appreciated.
13-08-24 01:55 PM
Try creating object with this code mentioned below
Library imports
Microsoft.Office.Interop.Outlook
System.IO
iTextSharp.text
iTextSharp.text.pdf
Code State Input Parameters - Action Page - MSG to PDF
Input Parameters:
Code Stage
' Create an Outlook application instance
Dim outlookApp As New Application()
' Open the .msg file
Dim mailItem As MailItem = CType(outlookApp.Session.OpenSharedItem(msgFilePath), MailItem)
' Convert the email body to HTML
Dim htmlBody As String = mailItem.HTMLBody
' Create a new PDF document
Dim pdfDoc As New Document(PageSize.A4)
Dim writer As PdfWriter = PdfWriter.GetInstance(pdfDoc, New FileStream(pdfFilePath, FileMode.Create))
' Open the PDF document
pdfDoc.Open()
' Add the HTML content to the PDF document
Using sr As New StringReader(htmlBody)
XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr)
End Using
' Close the PDF document
pdfDoc.Close()
' Release Outlook COM objects
System.Runtime.InteropServices.Marshal.ReleaseComObject(mailItem)
System.Runtime.InteropServices.Marshal.ReleaseComObject(outlookApp)
' Final clean-up
mailItem = Nothing
outlookApp = Nothing
GC.Collect()
21-03-25 05:43 AM
To convert .MSG files to PDF, you can use DRS Softech MSG Converter Tool. This software allows you to convert multiple MSG files to PDF in bulk while maintaining the original formatting, metadata, and attachments. It provides options to preview the emails before conversion and offers advanced filters for selective file conversion. The tool ensures high-quality output without any data loss and is compatible with all Windows versions. With an easy-to-use interface, both technical and non-technical users can efficiently convert MSG files to PDF without hassle.
Wednesday
If you're looking for a quick way to convert .msg files to .pdf, Softaken MSG Converter is a tool you can count on. I used it recently to turn a large number of MSG emails into PDF format and it preserved everything: my attachments, formatting, and message details. It supports bulk conversion and doesn’t need Outlook installation and setup, which makes the conversion procedure much easier. It does the job smoothly on all Windows versions and has a clean interface that anyone can use. If you want a simple way to make your MSG emails readable and shareable as PDF files, this tool works great.