Send HTML Formatted Email


posted by Aman Dhally
11-09-2011

Downloads: 866
File size: 1kB
Views: 5,645

Embed
Send HTML Formatted Email
  1. ##############  Script start Here ########## 
  2. # $smtp variable contain the name/ip of your email server ## 
  3. # $to contain the email id whom you want to send email ### 
  4. # $from contain email of sender ### 
  5. # $Subject contain subject of the email.  
  6. # In Body we are defining some HTML coding in to our email message body 
  7. # <b> means BOLD  
  8. #<br> means Break go to next Line 
  9. #<a href> provide a link to the text 
  10. # <font color=red> , give the color to the font  
  11.  
  12. $smtp = "Exchange-Server" 
  13.  
  14. $to = "Aman Dhally <amandhally@gmail.com>" 
  15.  
  16. $from = "Aman Singh <aman.dhally@analysysmason.com>" 
  17.  
  18. $subject = "This is a Test of HTML Email"  
  19.  
  20. $body = "Dear <b><font color=red>$to</b></font> <br>" 
  21.  
  22. $body += "We are testing <b>HTML</b> email <br>" 
  23.  
  24. $body += "Click <a href=http://www.google.com>here</a> to open google <br>" 
  25.  
  26. #### Now send the email using \> Send-MailMessage  
  27.  
  28. send-MailMessage -SmtpServer $smtp -To $to -From $from -Subject $subject -Body $body -BodyAsHtml -Priority high 
  29.  
  30. ########### End of Script################ 

Hi,

Do you ever want to send a nicely coloured formatted HTML email to users using powershell?

if yes then this script is for you:)

fore more info : http://newdelhipowershellusergroup.blogspot.com/2011/10/send-html-formatted-email-using.html

Note: Please don't forget to send me the feedback, I am new to PowerShelland feedback encourage me to write more scripts.

Thanks

aman dhally

www.amandhally.net/blog

Copyright 2012 PowerShell.com. All rights reserved.