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.
Related
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.
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.
I'm trying to copy a document I have in my drive, save it as a PDF, and then email the PDF as an attachment. However, even though the PDF is always copied and sent correctly as an attachment, and is properly readable form the gmail "preview" when viewing the email chain, it is unreadable when downloaded (filetype is simply "file"). Both the original document, when viewed from my drive, and the PDF (when the document is saved as a PDF and downloaded from the drive) are readable.
To me this indicates that there is either a problem with the way I convert the document into a PDF, or the way I attach it.
Here is how I convert it to a PDF:
var newFile = DriveApp.createFile(copyFile.getAs('application/pdf'));
And here is how I attach it:
MailApp.sendEmail(email, subject, message, {
name : "senderEmail",
attachments : [invoicePdf]
});
I know that using the Document Google Scripts class it is possible to get a Document as a pdf using the application/pdf keyword.
I have been sending emails with attached PDFs in this manner for a while now to several people; I find it unlikely, but possible, that none of them brought this issue to my attention until recently. The attachments from both recent emails (from people who have confirmed to me that the attachments are unreadable) and older emails are unreadable for my when I go to those conversations in my gmail and download the attached PDFs.
Kindly change your this line
var newFile = DriveApp.createFile(copyFile.getAs('application/pdf'));
as follows
var newFile = DriveApp.createFile(copyFile.getAs('application/pdf')).setName("fileName.pdf");
So that drive name it with .pdf extension, so that it can be opened properly.
Background:
I have a script that iterates through emails (without any emails being selected) in an Outlook folder saving their attachments to the desktop.
Issue:
The attachment is a zip-file and I wonder if it is possible to save the decompressed file within (an .xls file) to the desktop instead?
Thank You!
The Outlook object model doesn't provide any method for that. You need to save the attached file on the disk and then unzip it programmatically.
If you try to use any search engine you can find the following links with a sample code:
VBA - Unzip files using VBA
Macro to Unzip Files - It's Just Creating Empty Folders
Unzip file(s) with the default Windows zip program (VBA)
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);