In Google App Scripts to process a list of email messages in my inbox. From the messages I need to get the from and to addresses of each message. When I use the message.getF
After you get the GmailMessage object, you can get the email address by first getting the RFC Header named "From" using GmailMessage.getHeader("From"), and then apply a certain Regular Expression to it.
Like this:
// Get email from RFC Header "From"
var rfcHeaderFrom = message.getHeader("From");
var rfcHeaderFromMailRegex = /[^< ]+(?=>)/g;
var mailSender = rfcHeaderFrom.match(rfcHeaderFromMailRegex)[0];
That will return an email address like: "user@example.com"