Skip to content

Instantly share code, notes, and snippets.

@najamsk
Last active August 29, 2015 14:07
Show Gist options
  • Save najamsk/65c8c432e3c3ce42f2ae to your computer and use it in GitHub Desktop.
Save najamsk/65c8c432e3c3ce42f2ae to your computer and use it in GitHub Desktop.
send emails with powershell
$EmailFrom = "from@mail.com"
$EmailTo = "to@mail.com"
$Subject = "emailing powershell report"
$Body = "this should work on remove server as well. test email"
$SMTPServer = "smtp.gmail.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("gmailUser", "gmailPasswor");
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment