Attach A Photo To An Email In Outlook 2011

Last week we had to send 200 mails using a CSV file. I have created a script that reads the information from the CSV file and add it in the mail. In this blog I stripped the script down to a minimum.

It may look like a large script but it is possible to combine the commands.

Attach a photo to an email in outlook 2011 onlineAttach A Photo To An Email In Outlook 2011

Attach A Photo To An Email In Outlook 2011 Online

<#
.SYNOPSIS
This function sends mail that can be included with an image
.DESCRIPTION
Use this script to easily send multiple mails to customers using powershell and use an HTML layout.
.NOTES
if you want to add more images you can copy/paste the embed image and assign a new variable and ID
.LINK
http://www.maartenpeeters.nl
#>
function SendMail
{
#Mail Variables
$EmailFrom = “NoReply@maartenpeeters.nl”
$EmailSubject = “Email including images in HTML”
$smtpServer = “<SMTP Server>”
$SendTo = “<SendToMail>”
$Image = “C:scriptsMailScriptTestImage.png”

#Embed Image
$att1 = new-object Net.Mail.Attachment($Image)
$att1.ContentType.MediaType = “image/png”
$att1.ContentId = “Attachment”

#More information on Mailmessage onhttp://technet.microsoft.com/en-us/library/dd347693.aspx
$mailmessage = New-Object system.net.mail.mailmessage

#Add attachment to the mail
$mailmessage.Attachments.Add($att1)

#Mail body
$body = “<p style=’font-family: Calibri, sans-serif’>
<img src=’cid:Attachment’ /><br />
This is a demonstration mail.
</p>”

#Mail info
$mailmessage.from = $emailfrom
$mailmessage.To.add($sendto)
$mailmessage.Subject = $emailsubject
$mailmessage.Body = $body
$mailmessage.IsBodyHTML = $true
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$SMTPClient.Send($mailmessage)

#Dispose attachments
$att1.dispose()

}
SendMail

Any comments or improvements on this script are welcome.

Result:

Photo2011

Attach A Photo To An Email In Outlook 2011

Sorry for not replying on a timely manner. I recognized that you want to insert photos on the body of the email and not as an attachment. Allow me to help you on your query. I want to confirm if the photos you want to include in the body of the email are saved on your computer or pictures coming from web. Optionally, you may add text. From the File menu, select Save As Type your File name and select HTML as the file type. Close the open window. Part 2: Link the HTML file to your Email Signature. Now that the file with your image and text is saved, you need to point your email program to it. From the Tools menu, select Options. Position the cursor where you want the image then click the Picture button on the right. Select the picture and click Insert to insert the image as an embedded image. This will include the image as an attachment. If you want to add a hyperlink to the image, click the Hyperlink button. See 'Add a logo or image to your signature' section in this article. As per the header, you may have to manually insert the picture in the front of the message body. Or you may create a message template with the image banner inserted, so that so can create email based on the template whenever you want. Hope this can be helpful. In Outlook 2007, please click the Tools Trust Center. In Outlook 2010 and 2013, please click the File Options to open the Outlook Options dialog box, and then click the Trust Center Trust Center Settings in the Outlook Options dialog box. See screen shot: Step 2: In the Trust Center dialog box, click the E-mail Security in the left bar.