Hi Guys,
Did you ever tried to send HTML formatted colour coded email using PowerShell ? I was trying to do it but didn’t get any good and useful information on it, but i finally manage to get it done.
So lets start:
For example i am sending a test email from my official account to my GMAIL account.
the script will look like this:############## Script start Here ##########
# $smtp variable contain the name/ip of your email server ##
# $to contain the email id whom you want to send email ###
# $from contain email of sender ###
# $Subject contain subject of the email.
# In Body we are defining some HTML coding in to our email message body
# means BOLD
#
means Break go to next Line
# provide a link to the text
# , give the color to the font
$smtp = “Exchange-Server”
$to = “Aman Dhally <amandhally@gmail.com>”
$from = “Aman Singh <aman.dhally@analysysmason.com>”
$subject = “This is a Test of HTML Email”
$body = “Dear $to
”
$body += “We are testing HTML email
”
$body += “Click http://www.google.com>here to open google
”
#### Now send the email using \> Send-MailMessage
send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml -Priority high
########### End of Script################
Did you ever tried to send HTML formatted colour coded email using PowerShell ? I was trying to do it but didn’t get any good and useful information on it, but i finally manage to get it done.
So lets start:
For example i am sending a test email from my official account to my GMAIL account.
the script will look like this:############## Script start Here ##########
# $smtp variable contain the name/ip of your email server ##
# $to contain the email id whom you want to send email ###
# $from contain email of sender ###
# $Subject contain subject of the email.
# In Body we are defining some HTML coding in to our email message body
# means BOLD
#
means Break go to next Line
# provide a link to the text
# , give the color to the font
$smtp = “Exchange-Server”
$to = “Aman Dhally <amandhally@gmail.com>”
$from = “Aman Singh <aman.dhally@analysysmason.com>”
$subject = “This is a Test of HTML Email”
$body = “Dear $to
”
$body += “We are testing HTML email
”
$body += “Click http://www.google.com>here to open google
”
#### Now send the email using \> Send-MailMessage
send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml -Priority high
########### End of Script################
Note: Make sure you use –BodyasHtml parameter in Send-MailMessage otherwise it send as plain text format.
Now lets see how this email will look like 🙂
![]()
Cool!!! it look exactly how we have define it in our Script 🙂
Download the script from this link : http://gallery.technet.microsoft.com/scriptcenter/Send-HTML-Formatted-email-26925a96
take care
aman dhally
I have been looking for a way for my script output that is sent in an email to look a lot “prettier” so this is a good find. Thanks!!!
-Rachael
Hi Rachael.
I glad that this helps you 🙂
thanks
aman