AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Ads
4.2K members online now
4.2K members online now
Dive into advanced features like Remarketing, Flexible Bid Strategies, AdWords Editor, and AdWords Scripts
Guide Me
star_border
Reply

How to add HTML into email script

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi guys,

 

How would I add HTML to an Adwords Script? I'm just having trouble getting the syntax correct.

 

For example if I have a basic script that sends an email like the one below:

 

  MailApp.sendEmail('email address@hotmail.com',
                ' Email title',
                    'body of email' );

 

 

How would I add the below HTML table into the body of the email?

 

<table style="width:100%">
  <tr>
    <td>name 1</td>
    <td>address 1</td>
    <td>age 1</td>
  </tr>
  <tr>
    <td>name 2</td>
    <td>address 2</td>
    <td>age 2</td>
  </tr>
</table>

 

Any help would be greatly appreciated. Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author bran b
March 2016

Re: How to add HTML into email script

Explorer ✭ ☆ ☆
# 2
Explorer ✭ ☆ ☆

Hello Bran.

This is a simple change you need to do:
You need to add the "options" object to MailApp.sendEmail:

MailApp.sendEmail('email address@hotmail.com',' Email title','body of email',{'htmlBody':'body of email'});
Take your table for example:

 

var mailBody = '<table style="width:100%"><tr><td>name 1</td><td>address 1</td><td>age 1</td></tr><tr><td>name 2</td><td>address 2</td><td>age 2</td></tr></table>'
MailApp.sendEmail('email address@hotmail.com',' Email title',mailBody,{'htmlBody':mailBody});

Here is the link for more information

https://developers.google.com/apps-script/reference/mail/mail-app#sendemailrecipient-subject-body-op...

See if that works for you.

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author bran b
March 2016

Re: How to add HTML into email script

Explorer ✭ ☆ ☆
# 2
Explorer ✭ ☆ ☆

Hello Bran.

This is a simple change you need to do:
You need to add the "options" object to MailApp.sendEmail:

MailApp.sendEmail('email address@hotmail.com',' Email title','body of email',{'htmlBody':'body of email'});
Take your table for example:

 

var mailBody = '<table style="width:100%"><tr><td>name 1</td><td>address 1</td><td>age 1</td></tr><tr><td>name 2</td><td>address 2</td><td>age 2</td></tr></table>'
MailApp.sendEmail('email address@hotmail.com',' Email title',mailBody,{'htmlBody':mailBody});

Here is the link for more information

https://developers.google.com/apps-script/reference/mail/mail-app#sendemailrecipient-subject-body-op...

See if that works for you.

Re: How to add HTML into email script

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
That's worked Thanks Arik