Similar to: Getting only email address to display when using message.getFrom() in JavaMail but could not apply the solution.
Trying to use mailMessage.getFrom()
It appears that when using the getFrom()
method in a card, the name appears but not the email address as you described, which is counter to what is contained in the GmailMessage.getFrom() documentation.
I have taken the liberty of reporting this behaviour for you on Google's Issue Tracker:
You can hit the ☆ next to the issue number in the top left of this page which lets Google know more people are encountering this and so it is more likely to be seen to faster.
In the mean time, as the getFrom()
method still works within the Apps Script interface, you can obtain the email address from the return string of getFrom()
.
If you use Logger.log(mailMessage.getFrom())
, you get a return in the log of the form:
Firstname Lastname
So, all you need to do is replace:
var from = mailMessage.getFrom();
with:
var from = mailMessage.getFrom().split("<")[1].split(">")[0];
I hope this is helpful to you!