Sending reports by e-mail
After creating a report, you might want to send it to your boss or to yourself. The PowerShell Send-MailMessage
cmdlet can send e-mail messages using an SMTP server. The syntax of this cmdlet is as follows:
Send-MailMessage [-To] <String[]> [-Subject] <String> [[-Body] <String>] [[-SmtpServer] <String>] [-Attachments <String[]>] [-Bcc <String[]>] [-BodyAsHtml] [-Cc <String[]>] [-Credential <PSCredential>] [-DeliveryNotificationOption <DeliveryNotificationOptions>] [-Encoding <Encoding>] [-Port <Int32>] [-Priority <MailPriority>] [-UseSsl] -From <String> [<CommonParameters>]
The –From
, -To
, and –Subject
parameters are required to send a report by e-mail. You can use the PowerShell $PSEmailServer
preference variable for the SMTP server. If the $PSEmailServer
variable is not set, you have to use the –SmtpServer
parameter.
You can send a report by putting it in the body of the e-mail...