Advertisement
Guest User

gmail mass email

a guest
Jun 7th, 2017
1,351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. $MailingList = Import-Csv C:\Users\root\Desktop\trash\mail.csv
  2.  
  3. $SMTPServer = "smtp.gmail.com"
  4. $SMTPPort = "587"
  5.  
  6. $Username = "sd@gmail.com"
  7. $Password = "gfff"
  8.  
  9. foreach ( $person in $MailingList)
  10. {
  11. $iName = $person.Name
  12. $iEmail = $person.Email
  13. $iAddress = $person.Address
  14.  
  15. $to = $person.Email
  16. $cc = "r00tsec@yandex.com"
  17. $subject = "Email Subject"
  18. $body = @"
  19.  
  20. Hi $iName,
  21.  
  22. Your address is : $iAddress
  23.  
  24. Regards,
  25. Your Name
  26.  
  27. "@
  28. $attachment = "C:\Users\root\Desktop\trash\test.txt"
  29.  
  30. $message = New-Object System.Net.Mail.MailMessage
  31. $message.subject = $subject
  32. $message.body = $body
  33. $message.to.add($to)
  34. $message.cc.add($cc)
  35. $message.from = $username
  36. $message.attachments.add($attachment)
  37.  
  38. $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
  39. $smtp.EnableSSL = $true
  40. $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
  41. $smtp.send($message)
  42. Write-Host Mail Sent to $iName
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement