Referring to this thread I'm able to retrieve my signature from Gmail with the code var signature = Gmail.Users.Settings.SendAs.list("me").sendAs.filter(function(account){if(account.isDefault){return true}})[0].signature;
But if I attach the retrieved HTML to the email body, the recipient see the raw code instead of my signature. I red many threads with this problem, but I'm unable to understand how fix this, I'm not expert with HTML. Please could someone help me?
CodePudding user response:
GmailApp
allows you to parse html using htmlBody
:
var signature = Gmail.Users.Settings.SendAs.list("me").sendAs.filter(function(account){if(account.isDefault){return true}})[0].signature;
GmailApp.sendEmail("[email protected]", "signature test", "test", {htmlBody: signature})
Update:
The signature of GmailApp.sendEmail
is:
sendEmail(recipient, subject, body, options)
or:
sendEmail(recipient, subject, body)
In your case, you need to use option 1.
replyTo
is specified using the options
object.
So, to summarize, here is your code:
mia_firma = '<p>' corpo '</p>' mia_firma; // concat htmlBody
MailApp.sendEmail(dest, // recipient email - string
sogg, // should be subject - string
corpo, // mail body - WILL BE IGNORED if you use htmlBody
{ // options - object
htmlBody: mia_firma,
replyTo: "[email protected]"
}
);
You can see the full documentation here