Issue with mail line break

2,075 views
Skip to first unread message

Lokesh DS

unread,
Feb 1, 2022, 12:38:13 PM2/1/22
to Google Apps Script Community
Hi,

I have a doubt please help me out here.

Whenever I send mail using apps script the body of the mail breaks after every 80 characters and proceeds to a new line.

Please help me how to avoid the auto line break here.

Tanaike

unread,
Feb 1, 2022, 9:02:25 PM2/1/22
to Google Apps Script Community
About "Whenever I send mail using apps script the body of the mail breaks after every 80 characters and proceeds to a new line.", can you provide your current script for replicating your issue?

Lokesh DS

unread,
Feb 2, 2022, 4:20:11 AM2/2/22
to google-apps-sc...@googlegroups.com
Hi Tanaike,

Here is the script im using.

function sendemail() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sss = ss.getSheetByName("Todays's demo");
  var lr = sss.getLastRow();

  for (var i = 2 ; i <= lr ; i++){
    var emails1 = sss.getRange(i,8).getValue();
    if(emails1 != ""){

var emails = sss.getRange(i,8).getValue();
var parentname = sss.getRange(i,4).getValue();
var studentname = sss.getRange(i,5).getValue();
var subject = "Zoom Link for "studentname + "'s Class with Pepkidz";
Logger.log(subject)
var slotstarttime = sss.getRange(i,11).getValue();
var slotdate = sss.getRange(i,9).getValue();
var teachernme = sss.getRange(i,17).getValue();
var zoomlink = sss.getRange(i,19).getValue();

var template = ss.getSheetByName("Template");
var templatebody = template.getRange(1,1).getValue();


var info = {
Parent_Name : parentname,
Student : studentname,
Slot_Start_Time : slotstarttime,
Demo_Date : slotdate,
Teacher_Name : teachernme,
Zoom_Link : zoomlink
}

var emailtext = templatebody.replace("{{Parent name}}",parentname).replace("{{Student}}",studentname).replace("{{Slot Start Time}}",slotstarttime).replace("{{Demo Date}}",slotdate).replace("{{Teacher Name}}",teachernme).replace("{{Zoom Link}}",zoomlink).replace("{{Student}}",studentname) ;
Logger.log(emailtext)

MailApp.sendEmail({to : emailssubject : subjectbody :emailtext })
  }}
  Browser.msgBox("Email's Sent")
}

On Wed, 2 Feb 2022 at 07:32, Tanaike <kanshi...@gmail.com> wrote:
About "Whenever I send mail using apps script the body of the mail breaks after every 80 characters and proceeds to a new line.", can you provide your current script for replicating your issue?

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/92b8b22d-c73c-466e-a018-794322159118n%40googlegroups.com.


--
Regards,
Lokesh

Tanaike

unread,
Feb 2, 2022, 6:49:56 AM2/2/22
to Google Apps Script Community
Thank you for replying. When I tested a text over 80 characters (without using the line break) to the text body of "MailApp.sendEmail" and retrieved the email, no line break is included in the email body. So, unfortunately, I cannot replicate your situation. I apologize for this. In order to correctly replicate your situation, can I ask you about the detailed flow for replicating your issue? By this, I would like to confirm it.

Clark Lind

unread,
Feb 2, 2022, 9:27:39 AM2/2/22
to Google Apps Script Community
This is only a hunch, but if you have "word wrap" turned on for Template cell A1, that may be adding the line feed. Try turning Word wrap off and see if that clears the problem.

Lokesh DS

unread,
Feb 3, 2022, 5:06:02 AM2/3/22
to google-apps-sc...@googlegroups.com
Hi Clark,

Thanks for response.

I tried wrapping still the issue not resolved.

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.


--
Regards,
Lokesh

Braja Patnaik

unread,
Feb 3, 2022, 7:33:54 AM2/3/22
to Google Apps Script Community
You can solve it by using GmailApp.sendEmail(emailssubject, emailtext), instead of MailApp.sendEmail

Lokesh DS

unread,
Feb 3, 2022, 11:24:21 AM2/3/22
to google-apps-sc...@googlegroups.com
Hi Braja Patnaik,

Thanks for the suggestion it worked,

Thanks, everyone for your help.



--
Regards,
Lokesh

Nikhil Chitmulwar

unread,
Mar 3, 2023, 6:39:37 AM3/3/23
to Google Apps Script Community
This one worked.

Thank you so much.

Reply all
Reply to author
Forward
0 new messages