How to Send an Email Using Windows PowerShell
Pinterest Stumbleupon Whatsapp

Email is so basic that most people don’t even think about it. Open up your mail client, type a message and recipient, and hit send. Not too tough, right?

But have you ever considered alternate ways to send emails? Whether you just want to geek out and do something techy or want to send an email without getting distracted by your inbox, there’s one hiding right on your Windows desktop.

How to Send an Email Using Windows PowerShell PowerShell Send Email

How to Send an Email Using PowerShell

  1. Open a PowerShell window by searching for PowerShell in the Start Menu.
  2. Use the below Gmail template to set up your email. The first lines that start with dollar signs set up variables for sending the message, while the Send-MailMessage line is the actual command:
    $From = ""
    $To = ""
    $Cc = ""
    $Attachment = "C:\users\Username\Documents\SomeTextFile.txt"
    $Subject = "Here's the Email Subject"
    $Body = "This is what I want to say"
    $SMTPServer = ""
    $SMTPPort = "587"
    Send-MailMessage -From $From -to $To -Cc $Cc -Subject $Subject -Body $Body -SmtpServer $SMTPServer -port $SMTPPort -UseSsl -Credential (Get-Credential) -Attachments $Attachment –DeliveryNotificationOption OnSuccess
  3. If using Yahoo mail, the server is and the port is 465. For Outlook, the server is with port 587.
  4. You can remove the Attachment and CC lines if you don’t need them. Make sure to remove them from the Send-MailMessage line too.
  5. Including –UseSsl makes sure the email sense securely. You can also include -DeliveryNotificationOption OnSuccess if you want to receive confirmation that it sent successfully.
  6. Once you issue the command, it will prompt you for your username and password thanks to(Get-Credential). Enter that, and your email is on its way!

For another geeky way to do this, check out how you can send an email with Google Sheets.

What do you think about this method of sending emails? What other cool ways do you know to do this? Share them with us in the comments below!

Enjoyed this article? Stay informed by joining our newsletter!

Enter your Email

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Baljeet Singh
    February 3, 2018 at 2:57 pm

    very very good and easy, expained very nicely. Thanks