Ed
Posts: 0
Joined: Wed May 13, 2015 6:14 pm

How to Format Sendgrid Emails

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!

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to Format Sendgrid Emails

Hello Ed,

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

Ed
Posts: 0
Joined: Wed May 13, 2015 6:14 pm

How to Format Sendgrid Emails

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;

Ed
Posts: 0
Joined: Wed May 13, 2015 6:14 pm

How to Format Sendgrid Emails

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;

Ed
Posts: 0
Joined: Wed May 13, 2015 6:14 pm

How to Format Sendgrid Emails

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?

Ed
Posts: 0
Joined: Wed May 13, 2015 6:14 pm

How to Format Sendgrid Emails

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

Ed
Posts: 0
Joined: Wed May 13, 2015 6:14 pm

How to Format Sendgrid Emails

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to Format Sendgrid Emails

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

Ed
Posts: 0
Joined: Wed May 13, 2015 6:14 pm

How to Format Sendgrid Emails

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to Format Sendgrid Emails

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

Return to “Issues”