在谷歌脚本

时间:2016-02-06 15:59:47

标签: javascript google-apps-script

我是否可以知道如何在Google Script中插入粗体,下划线,斜体,更改电子邮件正文的字体?这是我的例子,它是一封电子邮件,我想插入各种字体大小,粗体,下划线,添加链接等。

`function sendEmails(e){

 var UserName = e.values[3];

 var UserEmail = e.values[5];

 var date = e.values[0];

 var pin = e.values[4];

 var subject = "[LFR] Application Succeed!";

 var bodymessage = "Hi " + UserName + 

 "\n\n\n\nThank you for sending in your job application on " + date +
 "\n\nThe following is your Purchase Log Pin:\n" + pin +
 "\n\n\n\nBest Regards" +
 "\nLeoFresh Resorts OOA Team\n" +
  subject.strike();
MailApp.sendEmail(UserEmail, subject, bodymessage); }     

`

2 个答案:

答案 0 :(得分:0)

如果使用HTMLBody,则可以通过向要加下划线的文本添加自定义css样式来为电子邮件添加下划线。 e.g。

some random text <span style="text-decoration: underline">underlined text</span> back to normal

text-decoration具有以下有效值。

underline
line-through
overline

答案 1 :(得分:0)

发送电子邮件时可以使用htmlBody选项:

message += "<br>Here is an <span style="text-decoration: underline;font-style: italic; font-weight: bold;"> Underlined,bold and italic</span>text.";


  GmailApp.sendEmail(sendTo, subject, textbody, {htmlBody: message});

htmlBody如果设置,能够呈现HTML的设备将使用它而不是所需的body参数(此处为textbody);如果您有电子邮件的内嵌图像,则可以在HTML正文中添加可选的内联图像字段。

参见: https://developers.google.com/apps-script/reference/gmail/gmail-app#sendemailrecipient-subject-body-options