Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PowerShell cmdlet that sends an e-mail via Outlook, with address and subject as arguments and message body from pipe
Function Global:Send-Email {
Param (
Begin {
$Body = ""
Process {
$Body += "$BodyLine`r`n"
End {
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.BodyFormat = 1
$Mail.To = "$Address"
$Mail.Subject = "$Subject"
$Mail.Body = "$Body"
$Outlook = $null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment