Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $MailingList = Import-Csv C:\Users\root\Desktop\trash\mail.csv
- $SMTPServer = "smtp.gmail.com"
- $SMTPPort = "587"
- $Username = "sd@gmail.com"
- $Password = "gfff"
- foreach ( $person in $MailingList)
- {
- $iName = $person.Name
- $iEmail = $person.Email
- $iAddress = $person.Address
- $to = $person.Email
- $cc = "r00tsec@yandex.com"
- $subject = "Email Subject"
- $body = @"
- Hi $iName,
- Your address is : $iAddress
- Regards,
- Your Name
- "@
- $attachment = "C:\Users\root\Desktop\trash\test.txt"
- $message = New-Object System.Net.Mail.MailMessage
- $message.subject = $subject
- $message.body = $body
- $message.to.add($to)
- $message.cc.add($cc)
- $message.from = $username
- $message.attachments.add($attachment)
- $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
- $smtp.EnableSSL = $true
- $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
- $smtp.send($message)
- Write-Host Mail Sent to $iName
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement