The Multifunctioning DBA

Oct 28 2008   11:06PM GMT

Powershell Email

Colin Smith Colin Smith Profile: Colin Smith

Exchange Server ActiveSync

The other day I was out reading some blog posts and I ran across one that talked about needing to send an email to a ridiculous number of people. So many that they could not all be fit into the to and cc fields of Outlook. So I thought why not Powershell this. All you would need is a listing of the email addresses that you want to send the mail to and then a file that contains the body of the email. For the addresses I would hope that you have them in your contacts and then you can do an export to a file. Once you have that then type the body of the email into a file and now lets write a script to send it.

$users = get-content “path to file with listing of email addresses”

foreach ($user in $users)


$smtpServer = “name of smtp server to send mail”

$smtp = New-Object Net.Mail.SmtpClient($smtpServer)

$emailFrom = “”

$subject = “Some Subject Line”

foreach ($line in Get-Content “Path to file with body of email”)


$body += “$line `n”





So there you go. No limit on how many users this script will send the mail to. Any questions or comments please let me know and also goto to drop me an email.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: