简体   繁体   中英

Google App Script - Send long email from google sheet - email broken into lines

I tried to autosend mass emails from google script editor, using a list of email addresses on google sheet. I followed this tutorial.

I used my other gmail address as a test and succeeded in receiving the email, but I found that some longer sentences are broken into several lines that are not compatible with the browser size. I have tried the GmailApp.sendEmail method instead of the MailApp.sendEmail one, but the sentences are just broken in slight different ways.. However, the email format seems current when I sent it to my sender address..

Does anyone know how to send a complete normal long email? Many thanks!

After a few days of trial and error I have actually come to the solution myself.

@urwaCFC - Thank you very much for the suggestion, but unfortunately it does not work - the problem lies in the way gmail deals with plain text, not where the text comes from;

@ale13 - As I mentioned above, text added to gmail using GmailApp.sendEmail, without specifying options, is automatically dealt with as plain text. For some unknown reason, this plain text, if too long, will be broken up randomly into several in lines by gmail when sending the email. The method might work for you because your paragraphs or sentences are not that long.

My solution is to send the email as an html file by adding the following line before sending the mail:

Logger.log(emailText);

And then modifying the GmailApp.sendEmail argument as:

GmailApp.sendEmail(rowData.emailAddress, emailSubject, "", {htmlBody: emailText});

The issue is then solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM