在谷歌脚本中创建的电子邮件正文上应用下划线,粗体,斜体等

Apply Underlining, Bold, Italics etc. on email body created in google script

本文关键字:下划线 应用 粗体 斜体 正文 脚本 谷歌 创建 电子邮件      更新时间:2023-09-26

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

' 函数发送电子邮件(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); }     

'

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

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

文本修饰具有以下有效值。

underline
line-through
overline

您可以在发送电子邮件时使用 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正文中添加可选的inlineImages字段。

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