PowerShell Logo Small


This is the built-in help made by Microsoft for the command 'Send-MailMessage', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.


Sends an e-mail message.


Send-MailMessage [-To] <String[]> [-Subject] <String> [[-Body] [<String>]] [[-SmtpServer] [<String>]] [-Attachments [<String[]>]] [-Bcc [<String[]>]] [-BodyAsHtml] [-Cc
[<String[]>]] [-Credential [<PSCredential>]] [-DeliveryNotificationOption {None | OnSuccess | OnFailure | Delay | Never}] [-Encoding [<Encoding>]] [-InformationAction
{SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable [<System.String]>]] [-Port [<Int32>]] [-Priority {Normal | Low | High}] [-UseSsl]
-From <String> [<CommonParameters>]

Search powershellhelp.space


The Send-MailMessage cmdlet sends an e-mail message from within Windows PowerShell.



Online Version: http://go.microsoft.com/fwlink/p/?linkid=294010




-------------------------- EXAMPLE 1 --------------------------

PS C:\>send-mailmessage -to "User01 <user01@example.com>" -from "User02 <user02@example.com>" -subject "Test mail"

This command sends an e-mail message from User01 to User02.

The mail message has a subject, which is required, but it does not have a body, which is optional. Also, because the SmtpServer parameter is not specified, Send-MailMessage
uses the value of the $PSEmailServer preference variable for the SMTP server.

-------------------------- EXAMPLE 2 --------------------------

PS C:\>send-mailmessage -from "User01 <user01@example.com>" -to "User02 <user02@example.com>", "User03 <user03@example.com>" -subject "Sending the Attachment" -body "Forgot
to send the attachment. Sending now." -Attachments "data.csv" -priority High -dno onSuccess, onFailure -smtpServer smtp.fabrikam.com

This command sends an e-mail message with an attachment from User01 to two other users.

It specifies a priority value of "High" and requests a delivery notification by e-mail when the e-mail messages are delivered or when they fail.

-------------------------- EXAMPLE 3 --------------------------

PS C:\>send-mailmessage -to "User01 <user01@example.com>" -from "ITGroup <itdept@example.com>" -cc "User02 <user02@example.com>" -bcc "ITMgr <itmgr@example.com>" -subject
"Don't forget today's meeting!" -credential domain01\admin01 -useSSL

This command sends an e-mail message from User01 to the ITGroup mailing list with a copy (CC) to User02 and a blind carbon copy (BCC) to the IT manager (ITMgr).

The command uses the credentials of a domain administrator and the UseSSL parameter.