Created
February 10, 2015 00:36
-
-
Save ernestohs/b0519b3ec12855bdc9ff to your computer and use it in GitHub Desktop.
PowerShell: Send Email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$from = "Jhon Doe <jhon@doe.com>" | |
$subject = "This is my subject" | |
$body = @" | |
<strong>Cool html content</strong> | |
"@ | |
$smtpServer = "smtp.server.com" | |
$user = "smtpuser" | |
$password = "secretword" | |
$message = New-Object System.Net.Mail.MailMessage | |
$message.To.Add("this@guy.com") | |
$message.From = $from | |
$message.Subject = $subject | |
$message.IsBodyHTML = $true | |
$message.Body = $body | |
$message.Priority = [System.Net.Mail.MailPriority]::High | |
$smtp = New-Object Net.Mail.SmtpClient($smtpServer) | |
$smtp.Credentials = New-Object System.Net.NetworkCredential($user, $password) | |
$smtp.Send($message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment