Page 1 of 1

How to Format Sendgrid Emails

Posted: Sun Oct 18, 2015 8:21 am
by Ed

Hello,

Using Sendgrid, I applied the following Javascript (which I found in this forum) in order to combine multiple form fields into the main Text section of the email:

var text = "";
//Here you need to fill all fields you want send to email.
text += "EventTitle= " + Apperyio("EventTitle").val() + "";
text += "Company= " + Apperyio("Company").val() + "";
text += "first_Name= " + Apperyio("first_Name").val() + "";
text += "last_Name= " + Apperyio("last_Name").val() + "";
return text;

However, the email arrives unformatted as follows:

EventTitle= XYZ EventCompany= ABC Companyfirst_Name= Johnlast_Name= Doe

Instead, I would like it to be formatted as follows:

EventTitle= XYZ Event
Company= ABC Company
first_Name= John
last_Name= Doe

Thank you in advance!


How to Format Sendgrid Emails

Posted: Sun Oct 18, 2015 12:25 pm
by Serhii Kulibaba

Hello Ed,

You have to add newline symbol "\n" at the end of the each string


How to Format Sendgrid Emails

Posted: Sun Oct 18, 2015 8:10 pm
by Ed

Hello Sergiy,

Where exactly would you insert it each symbol? I tried it but it did not work.

var text = "";
//Here you need to fill all fields you want send to email.
text += "EventTitle= " + Apperyio("EventTitle").val() + "";
text += "Company= " + Apperyio("Company").val() + "";
text += "first_Name= " + Apperyio("first_Name").val() + "";
text += "last_Name= " + Apperyio("last_Name").val() + "";
return text;


How to Format Sendgrid Emails

Posted: Sun Oct 18, 2015 8:22 pm
by Ed

I tried the following but it did not work:

var text = "";
//Here you need to fill all fields you want send to email.
text += "EventTitle= " + Apperyio("EventTitle").val() + "\n";
text += "Company= " + Apperyio("Company").val() + "\n";
text += "first_Name= " + Apperyio("first_Name").val() + "\n";
text += "last_Name= " + Apperyio("last_Name").val() + "\n";
return text;


How to Format Sendgrid Emails

Posted: Sun Oct 18, 2015 9:01 pm
by Ed

Resolved it. I used "\n\n" (instead of "\n").

Also, is there a Javascript to permanently CC the same email address on every form submission in Sendgrid?


How to Format Sendgrid Emails

Posted: Sun Oct 18, 2015 9:09 pm
by Ed

For some reason "\n" does not work. However, "\n\n" works but it adds an extra line break as follows:

EventTitle= XYZ Event

Company= ABC Company

first_Name= John

last_Name= Doe

I want it to look like the following without the extra line break:

EventTitle= XYZ Event
Company= ABC Company
first_Name= John
last_Name= Doe


How to Format Sendgrid Emails

Posted: Sun Oct 18, 2015 10:00 pm
by Ed

Also, in addition to capturing the Text fields, how would I capture the value of "checked" checkboxes within the form?


How to Format Sendgrid Emails

Posted: Tue Oct 20, 2015 9:02 pm
by Serhii Kulibaba

You can check "\n\r" for a new line.

how would I capture the value of "checked" checkboxes within the form
Please use :checked selector for that functionality


How to Format Sendgrid Emails

Posted: Wed Oct 21, 2015 11:22 pm
by Ed

I tried "\n\r" but it is still returning the extra line break as follows:

EventTitle= XYZ Event

Company= ABC Company

first_Name= John

last_Name= Doe


How to Format Sendgrid Emails

Posted: Fri Oct 23, 2015 3:47 pm
by Serhii Kulibaba

Ed, you can use "html" parameter instead of "text" and send HTML-formatted mail instead of plain text.