Advertisement
jewishnuggets

SEND FILE FMAIL

Aug 6th, 2017
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. $SMTPServer = "smtp.gmail.com"
  2. $SMTPPort = "587"
  3. $Username = "jewishnuggets@gmail.com"
  4. $Password = "yiashbcejvbsjeil"
  5. $to = "tomjacksonhyde@gmail.com"
  6. $subject = "Email Subject"
  7. $body = "Insert body text here"
  8. $attachment = "H:\capture.png"
  9. $message = New-Object System.Net.Mail.MailMessage
  10. $message.subject = $subject
  11. $message.body = $body
  12. $message.to.add($to)
  13. $message.from = $username
  14. $message.attachments.add($attachment)
  15. $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
  16. $smtp.EnableSSL = $true
  17. $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
  18. $smtp.send($message)
  19. write-host "Mail Sent"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement