Skip to content Skip to sidebar Skip to footer

How To Use Html Spacing In Email Body Google Apps Script?

I am sending email from google sheet data via google apps script. But the problem is the spacing is not correctly formatted I have tried using ' ' but the spacing remains the same

Solution 1:

By default, html spaces are collapsed. You can set white-space to pre or pre-wrap to preserve spaces.

var body = "<body style='white-space:pre-wrap'>";
 for (var m=0;m<resultArr.length;m++) {
        body+= "For Part No "+resultArr[m][0].toString()+" " +"  Month   "+resultArr[m][1].toString()+",Quantity is "+resultArr[m][2].toString()+" <br>";
}
body += "</body>"

Solution 2:

Try this loop:

for (var m=0;m<resultArr.length;m++) {
        body+= "<tdstyle='font-family:Arial; font-size:15px;'>For Part No "+resultArr[m][0].toString()+" " +"</td><td>  Month   " +resultArr[m][1].toString()+"</td><td>Quantity is "+resultArr[m][2].toString()+"</td>";
}

add this table around the loop

<tablewidth="100%"border="0"cellspacing="0"cellpadding="0"><tbody><tr><!-- loop goes here --></tr></tbody></table>

The loop will create 3 columns while the rest of the code will create the code necessary for a table to hold.

Post a Comment for "How To Use Html Spacing In Email Body Google Apps Script?"