I use the following script to send auto confirmations from a spreadsheet which is synced with a google form.
function formSubmitReply(e) {
var userEmail = e.values[2];
MailApp.sendEmail(userEmail,
"Thanks for Volunteering",
" Hello\n\n"+
"Thanks you\n\n"+
"Have a great day\n\n",
{name:"ABC"});
}
The \n
takes the text to the next line. However, it's all left aligned. Is there anything I can add to make it right aligned? something like \r
?
Thanks
The text body of an email supports no formatting. You could embed tabs (
\t
) or spaces to try to push the text to the right; but how would you know how wide the recipient's display is?If you want to control the presentation of your email, you need to use the
htmlBody
option described here.You can affect basic formatting with embedded css styles, by wrapping the text of the email in
<div>
tags, and placing css property / value pairs in astyle
attribute. For example, this would produce right-aligned text (go ahead, "run" it and see):This example wraps the text version of the email body in
<div>
tags with our selected style, replacing the newline characters to html<br>
tags. When we send this email, both the text and html versions are included; recipients with email clients that support html will see the right-aligned html version, others will see the plain text.