Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Email Google应用程序脚本,如何从文档中获取带格式的文本,并将其用于正文发送电子邮件_Email_Google Apps Script_Google Docs - Fatal编程技术网

Email Google应用程序脚本,如何从文档中获取带格式的文本,并将其用于正文发送电子邮件

Email Google应用程序脚本,如何从文档中获取带格式的文本,并将其用于正文发送电子邮件,email,google-apps-script,google-docs,Email,Google Apps Script,Google Docs,我想从电子表格发送电子邮件,使用谷歌文档文件的内容发送邮件(电子邮件正文)。这就是我现在拥有的,很好用 *部分代码 var doc = DocumentApp.openById(row[9]); var message = doc.getText(); MailApp.sendEmail(emailAddress, subject, "Dear " + row[6] +"\n\n"+ message + "\n\n"+ row[1] + "\n" + row[2] + "\n" + row[3

我想从电子表格发送电子邮件,使用谷歌文档文件的内容发送邮件(电子邮件正文)。这就是我现在拥有的,很好用

*部分代码

var doc = DocumentApp.openById(row[9]);
var message = doc.getText();

MailApp.sendEmail(emailAddress, subject, "Dear " + row[6] +"\n\n"+ message + "\n\n"+ row[1] + "\n" + row[2] + "\n" + row[3] + "\n" + row[4]);
它工作得非常好,但电子邮件是纯文本的

我有一些格式,比如Blod/Colored/List格式。。。等等。 如何在电子邮件中保留这些格式

我尝试了getBody()或getparagration(),但它只返回“Document”或“段落,段落,段落”

提前谢谢

*供参考 我试过这个。 这很管用,但我正试图找到一个解决方案,直接使用富文本发送电子邮件。不使用html格式

function test_mail_() {
 var id = DocumentApp.getActiveDocument().getId();
 var url = "https://docs.google.com/feeds/download/documents/export/Export?id=" + id + "&exportFormat=html";
 var param = {
    method: "get",
    headers: {
        "Authorization": "Bearer " + ScriptApp.getOAuthToken()
    },
    muteHttpExceptions: true,
 };
 var html = UrlFetchApp.fetch(url, param).getContentText();
 var raw = Utilities.base64EncodeWebSafe("Subject: Test\r\n" +
    "From: " + Session.getActiveUser().getEmail() + "\r\n" +
    "To: test@gmail.com\r\n" +
    "Content-Type: text/html; charset=UTF-8\r\n\r\n" +
    html + "\r\n\r\n");
 var message = Gmail.newMessage();
 message.raw = raw;
 var sentMsg = Gmail.Users.Messages.send(message, 'test@gmail.com');
} 
这对我有用。希望这能有所帮助