When you drag a file form outlook inbox to say your desktop, it saves it as a MSG file, is it possible to change for file type? Ideally I would like pdf, but EML would also be exceptable.
It is so i can attached it to another PDF or phrase it in a php script.
No, it is your responsibility to convert MSG file format to any other format. You can use the Outlook Object Model for that - MailItem.SaveAs exports to the txt, RTF, HTML, MHTML, and Doc formats.
Related
I have a folder with 200ish msg files from Outlook which I need to put in a single CSV where each column represents one msg with corresponding subject, body, to etc.
Any good idea how to do that without doing it manually?
You can automate Outlook and Word to get the job done. For example, you can automate Outlook from Excel or otherwise in VBA. Read more about that in the Automating Outlook from a Visual Basic Application article.
The Outlook object model provides the NameSpace.OpenSharedItem method which opens a shared item from a specified path or URL. This method is used to open iCalendar appointment (.ics) files, vCard (.vcf) files, and Outlook message (.msg) files. The type of object returned by this method depends on the type of shared item opened. So, you can use that method to open the MSG file from the disk and then read its properties for filling a spreadsheet.
I want to printout a complete email to pdf. the standard printer is selected as microsoft Print to PDF. Running the printout method, a saveas window occures and I dont know, how to handle that programatically.
I still know the way to convert via a word object, but that does not work, as screenshots will not be printed and the header is missing. So, this is not an answer for me: Save complete email, body and header, as PDF
Can anybody tell me how to deal with the saveas dialog and the filename of the resulting pdf?
One possibility would be to print the mail to an xps file (print to file - how to do that). After that, I could convert xps to pdf using PDFSharp.
Regards and thanks,
Jan
The Word editor can be used for saving the message body as a PDF file.
Word.Document doc = mailItem.GetInspector.WordEditor;
doc.SaveAs2(fullPath, FileFormat: Word.WdSaveFormat.wdFormatPDF);
Note, you need to add a COM reference to the Word object model to your project before using its object model in the code.
I need a macro script to:
Convert/Print email body to PDF file
Save that file to a folder
Delete the email after
I'm pretty clueless on using scripts/macros on outlook. Would need step by step process if possible. I do have adobe program for converting installed.
You can save the message as a DOC file (OlSaveAsType.olDoc), then use the Word Object Model to convert it to PDF.
I have a question about saving the Microsoft Office format file like doc, xls to PDF. I am using the SavesAs option in VB.Net to convert the files to PDF programatically. However, I need to open the file differently to achieve this.
If file is an Excel, then I need to open it using excel API's and then perform SaveAs. Similarly with Word documents. Is there a way so that I can open this documents generically and then use SaveAs option to convert them to PDF irrespective of opening the files?
The Word API and Excel API are two distinct APIs, even though they may both have a SaveAs method. You will not be able to use the same call for both file types.
I am trying to generate a report html file and email it as an attachment with vb.net
I know how send mail and attachments.
Do I need to generate the html file, save it as an .html file to the local disk where the program runs, then add its file path to the attachment property to send it to the recipient?
It is going to be a rather large report, and I would like to send it as an attachment instead of directly inside of the email itself.
Thanks
Yes, you save the file to disk ant then add to the Attactments collection of the MailMessage. Here is the C# syntax to create an Attachment from a file on disk and add the attachment to the message. It will be similar for VB.Net.
Attachment att = new Attachment(filename);
message.Attachments.Add(att);