In this post we will see how to send email from PowerShell
Send-MailMessage is the new shell command which can be used to send emails from PowerShell command and below is the one liner command to send emails
-To "Rajkumar.Mcitp@outlook.com", "rajkumar.mcitp@yahoo.com"
-Subject "Subject of the Email"
-Body "Information that has to be displayed on the body of the email"
-SmtpServer smtpservername.domainname.com
-From ExchangeAdmin@domainname.com
-Attachments "C:\Scripts\Output.csv"
-Bcc Admin@domainname.com
-BodyAsHtml $True or $false
-Cc Admin1@domainname.com
-Credential Powershell Credential
-DeliveryNotificationOption $true
-Encoding Encoding Methods like ASCII, UTF8, UTF7, UTF32
-Port Port Number (25)
-Priority Normal, High, and Low
-UseSsl $true or $false
Below Sample shows the format which includes all the available parameters
Send-MailMessage is the new shell command which can be used to send emails from PowerShell command and below is the one liner command to send emails
Send-MailMessage -To rajkumar.mcitp@outlook.com -From ExchangeAdmin@DomainName.com -Subject "Subject Name" -SmtpServer servername.domainname.comBelow are the parameters available with Send-MailMessage
-To "Rajkumar.Mcitp@outlook.com", "rajkumar.mcitp@yahoo.com"
-Subject "Subject of the Email"
-Body "Information that has to be displayed on the body of the email"
-SmtpServer smtpservername.domainname.com
-From ExchangeAdmin@domainname.com
-Attachments "C:\Scripts\Output.csv"
-Bcc Admin@domainname.com
-BodyAsHtml $True or $false
-Cc Admin1@domainname.com
-Credential Powershell Credential
-DeliveryNotificationOption $true
-Encoding Encoding Methods like ASCII, UTF8, UTF7, UTF32
-Port Port Number (25)
-Priority Normal, High, and Low
-UseSsl $true or $false
Below Sample shows the format which includes all the available parameters
Send-MailMessage -To rajkumar.mcitp@outlook.com -From ExchangeAdmin@Chennai.com -Subject "Test Email" -SmtpServer "ExchangeServer@Chennai.com -Body "This is a Test Email" -Attachments "C:\Output.csv" -BodyAsHtml $True -Cc "admin1@chennai.com" -Bcc "Admin2@Chennai.com" -Port 25 -Prority High -UseSsl $falseNote: Send-MailMessage only works when PowerShell Version 2.0 or later
No comments:
Post a Comment