Skip to content

Instantly share code, notes, and snippets.

@daurrutia
Created July 6, 2018 12:42
Show Gist options
  • Save daurrutia/4aee25a1445333cd954071a33db6e883 to your computer and use it in GitHub Desktop.
Save daurrutia/4aee25a1445333cd954071a33db6e883 to your computer and use it in GitHub Desktop.
Send an email using PowerShell
##############################################################################
$From = "my_email@gmail.com"
$To = "your_email@yahoo.com.com"
$Cc = "friend_email@outlook.com"
#$Attachment = "C:\temp\Some file.txt"
$Subject = "Email Subject"
$Body = "Insert body text here"
$SMTPServer = "smtp.gmail.com"
$SMTPPort = "587"
Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject `
-Body $Body -SmtpServer $SMTPServer -port $SMTPPort -UseSsl `
-Credential (Get-Credential) #-Attachments $Attachment
##############################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment