HELP! Using Threads and Messages classes in GMAIL Service to find Bad Emails
ABSTRACT OF THE PROBLEM
I sent a bulk email to about 1800 recipients a few days ago. All of the bad email addresses (approximately 261) have returned their bounced email responses. Naturally, the format of the various email responders is different. Rather than go through each individual email response, I was hoping to pull those email responses into a spreadsheet, extract the failing email address from each one. The responder emails are all under a specific label in the gmail account.
My end result should be a list of emails to which I sent my original note. Every one of these emails failed. I have to send that list of emails to our HQ so they can update their list and remove the bad emails.
Progess so far
I wrote a script which pulls the messages from threads in label "FAILED EMAIL DELIVERY". Now I find a have several problems:
1) I'm only getting 100 messages returned. (I used logger to see that there are 4 threads, with 21, 100, 100, 1 messages).
2) I don't understand the structure of threads, labels and messages, so I don't exactly know which 100 messages are being returned
3) Extracting an email address using REGEX seems to be achievable, but I don't know exactly the Google REGEX format to match an Email address.
Any help here would be greatly appreciated.