SendEmail script Google spreadsheets - multiple options

五迷三道 提交于 2020-03-26 06:27:29

问题


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!


回答1:


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]
     });


来源:https://stackoverflow.com/questions/30146530/sendemail-script-google-spreadsheets-multiple-options

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!