[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How can I embed images in an HTML email message sent via Exchange Powershell?

Posted on 2015-01-29
4
Medium Priority
?
1,401 Views
Last Modified: 2015-01-30
I have a working Powershell script that looks at an input file for two variables (recipients and language code).  each email that is sent contains a header and footer image.  But, the email that Outlook receives doesn't automatically display the images.  the user has to allow Outlook to download the images.  Is there a way around this?  Is it possible to embed the images in the HTML formatted email that is sent via Powershell?

Here is my script below:

Start-Transcript -PATH UserImportLog.txt -append

# Language specific text
$Subject = @{
  en = @"
Service Request Approval
"@
  fr = @"
Approbation d’une demande de service
"@

}
$msg = @{
  en = @"
<img src="\\sharename\Images\header_en.png" /><br>
<p><b><font color="#FF9900">Service Request Approval:</font></b></p>

<p>You have been identified as the approver of one or several Service Requests.</p>

<p><b>Your action (approval / rejection / reassignment) is important because the requests cannot be fulfilled without your approval.</b></p>

<p>Therefore, please go to the portal to validate these requests by clicking on the following link: http://test.domain.com/pages/approval-

dashboard.aspx</p>

<p></p>

<p>For further information or assistance, please contact your local Service Desk.</p>

<p>Best regards,</p>

<p>The IS Team</p>

<p>PS: This e-mail was generated automatically. Please do not reply directly to this e-mail.</p>
<img src="\\sharename\Images\footer.png"><br>
"@
  fr = @"
<img src="\\sharename\Images\header_fr.png" /><br>
<p><b><font color="#FF9900">Approbation d&rsquo;une demande de service:</font></b></p>

<p>Vous avez &eacute;t&eacute; identifi&eacute; comme &eacute;tant l&rsquo;approbateur d&rsquo;une ou plusieurs demandes de services INIT.</p>

<p><b>Votre action (validation / refus / r&eacute;assignation) est importante car aucun traitement ne pourra &ecirc;tre effectu&eacute; par les

&eacute;quipes IS tant que ces demandes ne seront pas approuv&eacute;es.</b></p>

<p>Nous vous invitons donc &agrave; vous connecter &agrave; votre portail pour valider ces demandes en cliquant sur ce lien :

http://test.domain.com/pages/approval-dashboard.aspx</p>

<p></p>

<p>Pour tout compl&eacute;ment d&rsquo;information ou assistance, n&rsquo;h&eacute;sitez pas &agrave; contacter votre Service Desk.</p>

<p>Cordialement,</p>

<p>L&rsquo;&eacute;quipe IS</p>

<p>PS: Ce message a &eacute;t&eacute; envoy&eacute; automatiquement, merci de ne pas y r&eacute;pondre</p>
<img src="\\servername\Images\footer.png"><br>
"@
 
}

#Importing the input file with two variables (emailaddress,languagecode)

Import-Csv -Path UserImport.csv | foreach-object {
     
 
     Send-MailMessage -SmtpServer servername -From "smtpaddress" -To $_.emailaddress -BodyasHTML -subject $subject[$_.languagecode] -Body $msg

[$_.languagecode] -Encoding ([System.Text.Encoding]::UTF8)
}

Stop-Transcript
0
Comment
Question by:bcapello
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 2000 total points
ID: 40578487
Hi,
yes there is. You have to use inline images. There is a nice sample on the Powershell gallery:
https://gallery.technet.microsoft.com/scriptcenter/Send-MailMessage-3a920a6d

HTH
Rainer
0
 
LVL 5

Author Comment

by:bcapello
ID: 40578894
I'm using 'Send-MailMessage' cmdlet in Powershell.  -InlineAttachments is not a valid cmdlet.
0
 
LVL 5

Author Comment

by:bcapello
ID: 40578914
I am using Powershell v2.  -inlineattachments parameter only works with v3.
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 40579947
Note: The script shown modifies the standard Send-MailMessage cmdlet by adding -InlineAttachments. It works with PS2.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On September 18, Experts Exchange launched the first installment of the Help Bell, a new feature for Premium Members, Team Accounts, and Qualified Experts. The Help Bell will serve as an additional tool to help teams increase question visibility.
The main intent of this article is to make you aware of ‘Exchange fail to mount’ error, its effects, causes, and solution.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question