PowerShell Logo Small

Send-MailMessage



This is the built-in help made by Microsoft for the command 'Send-MailMessage', in PowerShell version 4 - as retrieved from Windows version 'Microsoft Windows 8.1 Enterprise' 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.

SYNOPSIS

Sends an e-mail message.

SYNTAX


Send-MailMessage [-To] <String[]> [-Subject] <String> [[-Body] <String>] [[-SmtpServer] <String>] [-Attachments <String[]>] [-Bcc <String[]>] [-BodyAsHtml] [-Cc <Stri
ng[]>] [-Credential <PSCredential>] [-DeliveryNotificationOption <DeliveryNotificationOptions>] [-Encoding <Encoding>] [-Port <Int32>] [-Priority <MailPriority>] [-Us
eSsl] -From <String> [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


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



<

RELATED LINKS


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

REMARKS

<

Examples


-------------------------- 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-MailM
essage 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>" -sub
ject "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.