Simple Powershell function to send email

This is a simple powershell function that sends email. There are a series of variables (i.e. $subject) that can be placed in as a parameter instead.To use this, you should make sure that your relay server is open to the host you are running this on. Please use the questions/answ

3.9 Star
18,947 times
Add to favorites
E-mail Twitter Digg Facebook
  • how to add credentials
    1 Posts | Last post June 12, 2018
    • Sorry. How can add user credential?
      run the file failure. the server need user credential.
      Liu Wei
  • In regard to the "To" field
    1 Posts | Last post July 23, 2014
    •  - how would i define it as function. Also how do it work as a parameter ie. does it prompt me to enter the email address ? thanks in advance
  • To
    2 Posts | Last post January 14, 2014
    • Sorry but I have not seen in your script "To" field...
    • Hi,
      Its a variable named $emailTo that is passed to the function as a parameter.  You could also define this within the function itself and not pass a parameter.  Does that help?
  • Attachment
    2 Posts | Last post June 17, 2013
    • Please let me know how to add attachments... and also let me know how to print attachment in Msg body.
    • You should be able to add these lines at the top:
      $file = "C:\temp\attachment.csv"
      $att = new-object Net.Mail.Attachment($file)
      And then right before the line that contains "smtp.send" add:
      This is from if you want to have a look.