SendEmail脚本Google电子表格 - 多个选项 [英] SendEmail script Google spreadsheets - multiple options

查看:231
本文介绍了SendEmail脚本Google电子表格 - 多个选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过Google电子表格发送一封电子邮件,其中包含多个选项:如果我在代码中键入第一个附件,然后键入htlmBody,则可以使用多个选项: b
$ b

电子邮件发送正确的内容和结构,但两个附件不会出现

  MailApp.sendEmail(收件人,主题, {attachments:[blob,blob1]},{htmlBody:html}); 

如果我在代码中键入第一个htmlBody和附件,如下所示,身体[对象物体],但两个附件存在!

  MailApp.sendEmail(收件人,主题,{htmlBody:html},{附件:[blob,blob1]}); 

我做错了什么?为什么我不能同时使用?而在这种情况下,我需要添加一个cc选项?



我已经尝试过使用一个附件,结果是一样的!

解决方案

https: //developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String,Object)



<$ p $ (
htmlBody:html,附件:[blob,blob1]
});

如果您知道它们具有HTML,则可以用空字符串替换不带HTML的正文文本,但占位符并且空字符串必须存在。

  GmailApp.sendEmail(收件人,主题,'',{
htmlBody:html ,附件:[blob,blob1]
});


I'm trying to send out an email from google spreadsheets with multiple options:

if I type first attachments and then htlmBody in the code, like below, the email goes out with the correct body content and structure but the two attachments don't appear

MailApp.sendEmail(recipient, subject,{attachments:[blob,blob1]} ,{htmlBody:html});

While if I type first htmlBody and then attachments in the code, like below, the email goes out with the body "[object Object]" but the two attachments are present!

MailApp.sendEmail(recipient, subject ,{htmlBody:html},{attachments:[blob,blob1]});

What am I doing wrong? Why I can't use both? And in the case i would need to add a "cc" option?

I already tried with only one attachment and the result is the same!

解决方案

https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String,Object)

GmailApp.sendEmail(recipient, subject , 'body if no html', {
     htmlBody:html, attachments: [blob,blob1]
 });

if you know they have HTML you can replace the no HTML body text with an empty string but the placeholder and empty string must be there.

GmailApp.sendEmail(recipient, subject , '', {
         htmlBody:html, attachments: [blob,blob1]
     });

这篇关于SendEmail脚本Google电子表格 - 多个选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆