A piece of my work around PowerShell and IIS (or usefull things I've found on the web). Mostly some reminders for myself!

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 - fabricezerrouki@hotmail.com
    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]hotmail.com
    Other Address;other.address@domain.com
    Any Address;anyaddress@domain.com

I am truly happy to glance at this blog posts which consists of plenty of valuable data, thanks for providing these kinds of information.

Norberto Hrovat
Norberto Hrovat

I want to thank you for this great read!! I definitely enjoyed every bit of it. I’ve got you saved as a favorite to check out new things you post…

Oliver Rincones
Oliver Rincones

Hey there! I just want to offer you a huge thumbs up for the great information you’ve got right here on this post. I’ll be coming back to your blog for more soon.

Chauncey Okuna
Chauncey Okuna

You have made some really good points there. I checked on the net for more information about the issue and found most people will go along with your views on this web site.


Leave a Reply

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

Scroll to Top