Book Image

Microsoft Exchange 2010 PowerShell Cookbook

Book Image

Microsoft Exchange 2010 PowerShell Cookbook

Overview of this book

Table of Contents (22 chapters)
Microsoft Exchange 2010 PowerShell Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Sending SMTP e-mails through PowerShell


As an Exchange administrator, will probably need an automated solution for sending e-mails from your PowerShell scripts. Whether it's for sending notifications to users in a specific database or e-mailing the output of your scripts to a reporting mailbox, the transmission of messages like these will prove very useful in performing common day-to-day administrative scripting tasks. In this recipe, we'll take a look at how you can send SMTP e-mail messages from PowerShell to the recipients in your Exchange organization.

How to do it...

PowerShell v2 includes a core cmdlet that can be used to send e-mail messages via SMTP to one or more recipients. Use the following syntax to send an e-mail message:

Send-MailMessage -To [email protected] `
-From [email protected] `
-Subject "Test E-mail" `
-Body "This is just a test" `
-SmtpServer ex01.contoso.com

How it works...

In PowerShell v1, the Send-MailMessage cmdlet didn't exist. In the early days before...