作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在使用以下脚本让谷歌电子表格通过电子邮件将我的谷歌表单回复发送给我。电子邮件中的所有文本都是纯文本,但我希望标题为粗体文本。我尝试了几种将粗体文本的 java 命令添加到代码中来完成此操作的变体,但我基本上是猜测,因为我的代码编写经验为零。有可能吗?我的脚本应该如何才能成功?谢谢。
function sendFormByEmail(e) {
var emailSubject = "MOD Report";
// Set with your email address or a comma-separated list of email addresses.
var yourEmail = "xxxx@xxxx.com";
// Set with your spreadsheet's key, found in the URL when viewing your spreadsheet.
var docKey = "xxxx-xxxx-xxxx-xxxx";
// If you want the script to auto send to all of the spreadsheet's editors, set this value as 1.
// Otherwise set to 0 and it will send to the yourEmail values.
var useEditors = 0;
// Have you added columns that are not being used in your form? If so, set this value to
// the NUMBER of the last column that is used in your form.
// for example, Column C is the number 3
var extraColumns = 0;
if (useEditors) {
var editors = DocsList.getFileById(docKey).getEditors();
if (editors) {
var notify = editors.join(',');
} else var notify = yourEmail;
} else {
var notify = yourEmail;
}
// The variable e holds all the submission values in an array.
// Loop through the array and append values to the body.
var s = SpreadsheetApp.getActive().getSheetByName("FormResponses1");
if (extraColumns){
var headers = s.getRange(1,1,1,extraColumns).getValues()[0];
} else var headers = s.getRange(1,1,1,s.getLastColumn()).getValues()[0];
var message = "";
for(var i in headers) {
message += headers[i] + ' = '+ e.values[i].toString() + '\n\n';
}
MailApp.sendEmail(notify, emailSubject, message);
}
最佳答案
您需要使用htmlBody高级参数。
Google Documentation - Class MailApp
注意:HTML 粗体标签:<b>text here</b>
function sendEmail() {
var message = "This is <b>the</b> message";
MailApp.sendEmail({
to: "theEmail@example.com",
subject: "This is the subject line",
htmlBody: "<br>" +
"inline text" +
message,
});
}
关于javascript - 如何使用粗体文本通过电子邮件发送谷歌表单数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28245173/
下面是我用来制作 1px 文本描边轮廓的代码。但是如何使轮廓变粗呢?如果我只是用“5px”替换所有“1px”,结果看起来很疯狂。 HTML Hello! CSS .element { color:
我是一名优秀的程序员,十分优秀!