generating an html attachment vb.net - vb.net

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);

Related

Outlook Folder with MSG Files, transfer to a CSV

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.

Copy Contents of Outlook Attachment

I have an Outlook VBA macro that copies the contents of an email and saves them as a word document, using
activeMessage.GetInspector().WordEditor.Range.FormattedText.Copy
I'd like to change this to copy the contents of the email attachments instead. Is there a simple way to do this?
No, you will need to save the attachment as a file (Attachment.SaveAsFile), open it (depends on the file type), then access its data.

Macro to Convert Inline Image to Attachment - MS Outlook

When I take a snippet or screenshot of something I'm working on and need to send it in an e-mail (MS Outlook), I don't always want to paste it in-line in the HTML body of the e-mail. There are times where I would like to add the image as an attachment.
In the interest of making this repetitive task a bit more efficient, is it possible for me to accomplish this without having to first save the image/screenshot and add an attachment manually? Perhaps a macro to convert an in-line image in my e-mail to an attachment on the same e-mail?
Downloading add-ons or plugin-ins is a no go; I work in a large corporate environment where this is near impossible to do.
Thank you!
What exactly do you mean by inline images? Images hosted on the remote HTTP servers and referenced by the HTML body? Or embedded image attachment referenced by the HTML body by their cid's? In the latter case, the attachments are already in the MailItem.Attachments collection.
You cannot simply convert an inline (embedded image) image into an attachment, you will need to save the inline attachment to a folder location, delete the inline attachment, and reattach the saved attachment.

Outlook - save/convert email body to PDF

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.

Outlook Save MHT - Include BCC, Exclude Embedded Items, Display Addresses

I use C# and the Outlook 2010 object model to save Outlook emails to MHT format (MIME HTML). I have no problem saving an email as an MHT.
//mi is a MailItem
//Save As MHT
mi.SaveAs(#"D:\test.mht", OlSaveAsType.olMHTML);
There are aspects of the resulting MHT that I would like to customize.
An Outlook-generated MHT file does not display the Bcc line of emails known to have Bcc recipients. These emails are taken from a sender's email store. Are there options to force the display of the Bcc line?
If the source email is a rich text formatted email and contains embedded files, Outlook stores the embedded files in the resulting MHT. Outlook does this well. However, I would like to purge the embedded files. Are there options to force Outlook not to write embedded files to the MHT? Saving as plain HTML is not an option because I want to retain in-line images.
An Outlook-generated MHT file shows the display name of each recipient. I would like for the MHT file to show the display name and the email address of each recipient. Is there a way to do this?
There is no way to do that, you would need to generate the MHT file yourself.