gpt4 book ai didi

google-apps-script - Apps脚本-发送电子邮件-将电子邮件内容设置为粗体-将Array.toString的结果格式设置为粗体

转载 作者:行者123 更新时间:2023-12-02 03:03:26 26 4
gpt4 key购买 nike

每当提交Google表单时,我的代码都会发送电子邮件通知。它可以工作,但是我希望收集的表单数据在电子邮件中以粗体显示。

for(var i in headers) 
message += headers[i] + ': '+ e.namedValues[headers[i]].toString() + "\n\n";


function sendFormByEmail(e)
{
var s = SpreadsheetApp.getActiveSheet();
var headers = s.getRange(1, 1, 1, s.getLastColumn()).getValues()[0];
var message = "";
var data = s.getRange(1, 1, 1, s.getLastColumn()).getValues()[0];
var subject = "";

//Get active Spreadsheet
var ss = SpreadsheetApp.getActiveSpreadsheet();

//Get Sheet called 'Form responses 1'
var fr1 = ss.getSheetByName("Form responses 1");

//Get all emails from 'Emails' tab
var emails = ss.getSheetByName("Emails");
var numRows = emails.getLastRow();
var emailTo = emails.getRange(2, 2, numRows, 1).getValues();

// The variable e holds all the form values in an array.
// Loop through the array and append values to the body.

for(var i in headers)
message += headers[i] + ': '+ e.namedValues[headers[i]].toString() + "\n\n";

// Insert variables from the spreadsheet into the subject.
// In this case, I wanted the part number as part of the
// email subject. These are the 3rd and 16th columns in my form.
// This creates an email subject like "Parts Inquiry Submission: 729302"
subject += e.namedValues[headers[1]].toString();

// Send the email
MailApp.sendEmail(emailTo, subject, message);

// Based off of a script originally posted by Amit Agarwal - www.labnol.org
// Credit to Henrique Abreu for fixing the sort order
}

最佳答案

首先,必须在htmlBody的第4个参数中使用高级参数sendEmail(),并且需要制作body参数和空字符串。

sendEmail(收件人,主题,正文,选项)

码:

message = "<strong>" + message + "</strong>";//Wrap message in bold tags

var options = {
"htmlBody":message
}

// Send the email
MailApp.sendEmail(emailTo, subject, "",options);//Make email body empty string

关于google-apps-script - Apps脚本-发送电子邮件-将电子邮件内容设置为粗体-将Array.toString的结果格式设置为粗体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44397168/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com