Menü schliessen
Created: December 5th 2017
Last updated: February 10th 2023
Categories: Databases
Author: Marcus Fleuti

[SOLVED] Bulk mailing: Generate a CSV list containing all rejected email addresses very simple with Thunderbird | REGEX | Notepad++

Donation Section: Background
Monero Badge: QR-Code
Monero Badge: Logo Icon Donate with Monero Badge: Logo Text
82uymVXLkvVbB4c4JpTd1tYm1yj1cKPKR2wqmw3XF8YXKTmY7JrTriP4pVwp2EJYBnCFdXhLq4zfFA6ic7VAWCFX5wfQbCC

Why generating an address list of all rejected e-mail recipients and exporting it into a CSV when using bulk mailing?

We are sending out mass e-mails (bulk mails) and we will return some rejection errors - almost certainly. In many cases this is handled by a bulk mailing application for you. But in some cases you might just have access to your clients e-mail account containing hundrets or thousands of those rejection e-mails. The question now is: How do you manage to export all the addresses of these rejected e-mails into one CSV file (list), that enabled you to insert those addresses into your address list database to handle exclusions/deletions? Well we just had this issue and this is how we solved it:

  1. Download Mozilla Thunderbird here: https://www.mozilla.org/thunderbird/
  2. Set the e-mail account that contains all the bulk mail rejection e-mails
  3. Download the following Thunderbird Extension: https://addons.mozilla.org/de/thunderbird/addon/importexporttools/
  4. Restart Thunderbird
  5. Download Notepad++ Editor here: https://notepad-plus-plus.org/download

Exporting rejected e-mail addresses into a CSV file and generate an address list

  1. Select the folder that contains the rejected e-mail addresses in Thunderbird:
    Bulk mailing: Generate CSV list from all rejected addresses
  2. Select Extras -> ImportExportTools -> Export this folder to export all E-Mails into 1 file
    Bulk mailing: Generate CSV list from all rejected addresses
  3. It will generate a file like this:
  4. Open up the file in Notepad++ (right click onto the file)
    Bulk mailing: Generate CSV list from all rejected addresses
  5. Set the cursor to be on first position of the file (before the first word)
  6. Select Search -> Replace
    Bulk mailing: Generate CSV list from all rejected addresses
  7. Enter the following string and set the options according to the screenshot below
      1. Search string:
        .*?Final-Recipient.*?(?:rfc822;\s*<|rfc822;\s*)([a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*).*?(?=(Final-Recipient)|\z)
      2. Alternative search string:
        In case you want to find ALL e-mail addresses anywhere in all e-mails (header + body - just everything) here's a working e-mail REGEX search string:

        .*?(([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5}))|(?:.*?\z)
      3. Replace string:
        If you like each address to be on separate line:

        $1\r\n

        If you like addresses to be separated by comma or semikolon:

        $1,
  8. Screenshot: Watch out to select all options properly and click ont he "Replace all" button:
    Bulk mailing: Generate CSV list from all rejected addresses
  9. The list will be filtered properly.

Find more

Find other useful REGEX functions here: https://www.lexo.ch/blog/tag/regex/