MassMail
Here’s a script to send massmails. It allows to send the same message many times, one to each email address defined in the associated text file.
- The script
<# .SYNOPSIS MassMail - Automatic email sending. .DESCRIPTION MassMail - Automatic email sending Allow to send massmail .NOTES File Name : MassMail.ps1 Author : Fabrice ZERROUKI - fabricezerrouki@hotmail.com .EXAMPLE PS D:\>MassMail.ps1 Gets names and addresses list from a 'RecipientsAddresses.txt' file and send an email to each one. #> if (!(Test-Path .\RecipientsAddresses.txt)) { Write-Host "Error: Can't find the addresses List. Please, create a `"RecipientsAddresses.txt`" file containing the recipients list in the script directory." -ForegroundColor DarkRed ; break } $addresses=Get-Content .\RecipientsAddresses.txt $addresses=$addresses -replace "\[at\]","@" ForEach ($address in $addresses) { $RecipientName=($address.split(";"))[0] $MailTo=($address.split(";"))[1] $MailSubject="MassMail Subject" $MailFrom="mailfrom@domain.com" $SMTPServer="smtp.server.com" # Possible Values : High, Normal or Low $Priority="Normal" # HTML support $MailBody=@" <html><span style='font-family: Tahoma; font-size: 12px;' > Hi $RecipientName,<br /> <br /> this is a test message, sended in mass...<br /> ----------------------------------------------------------------------------</span><br /> <span style='font-family: Tahoma; font-size: 10px;' ><strong>DO NOT REPLY</strong> to this e-mail, as e-mails to this address are not monitored and will not be received or responded to.<br /> <br /></span> <span style='font-family: Tahoma; font-size: 12px; color: darkblue;' >The contents of this e-mail and any file transmitted with it are confidential and intended solely for the individual or entity to whom they are addressed. The content may also contain legal, professional or other privileged information. If you received this e-mail in error, please destroy it immediately. You should not copy or use it for any purpose nor disclose its contents to any other person.</span></html> "@ Send-MailMessage -To $MailTo -Subject $MailSubject -From $MailFrom -SmtpServer $SMTPServer -Priority $Priority -BodyAsHtml $MailBody Write-Host "Mail sent to $MailTo" -ForegroundColor DarkGreen }
Fab Hotmail;fabricezerrouki[at]hotmail.com Other Address;other.address@domain.com Any Address;anyaddress@domain.com