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
  • <#
        MassMail - Automatic email sending.
        MassMail - Automatic email sending
        Allow to send massmail
        File Name  : MassMail.ps1
        Author     : Fabrice ZERROUKI -
        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)
    $MailSubject="MassMail Subject"
    # Possible Values : High, Normal or Low
    # HTML support
    <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 />&nbsp;<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
  • An example of the addresses list file’s content (‘RecipientsAddresses.txt’)
  • Fab Hotmail;fabricezerrouki[at]
    Other Address;
    Any Address;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top