Sending Mails With Outlook

by Jan 4, 2011

You can use PowerShell to automatically prepare your e-mails and send them via Outlook. The code requires that you first launch Outlook as an application. It will not work when Outlook has not yet been started.

Start-Process Outlook
$o = New-Object -com Outlook.Application
$mail = $o.CreateItem(0)
$mail.subject = "Test message"
$mail.body = "First line`nSecond Line`nThird line"
$mail.To = ""

Twitter This Tip!
ReTweet this Tip!