April 7, 2010

How to send an email ?

$message = '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"><html><head></head><body lang=FR-CA>This is the body of the message</body></html>"
send-MailMessage -to "toto@domain.com" -Encoding ([System.Text.Encoding]::UTF8) -subject "PowerShell Rocs" -from "bozo@domain.com"  -bodyasHTML -body $message -smtpserver "mysmtp.domain.com"

If you want to send your mail to multiple recipients, use the following syntax for the -to  parameter :

@("bozo@domain.com","toto@domain.com")

No comments:

Post a Comment