Sending An Email from PowerShell
It’s easy to send an email from PowerShell, and it’s really useful for notifying yourself of the completion of a long-running script.
It’s also a way to document what ran when, if you are like me and running hundreds of scripts and need a way to organize documentation on when you run things.
Just alter the parameters below, and let ‘er rip and spam yourself!
param( [string] $From = "server@joelDomain.com", [string] $To = "joelplaut@joelDomain.com", [string] $Title = "title", [string] $Body = "body" ) $SmtpClient = New-Object System.Net.Mail.SmtpClient $SmtpServer = "mail.domainserver.com" $SmtpClient.host = $SmtpServer $SmtpClient.Send($From,$To,$Title,$Body) |
Want to talk?
Drop us a line. We are here to answer your questions 24*7.