Wondering how to include returns in the body of an email
9:47 pm on Feb 4, 2012 (gmt 0)
Just wondering if there is a way to include returns in the body of an email which is made up of primarily variables.
var email = "email@example.com"; var subject = "Subject Here"; var body1 = "Body 1 segment"; var body1 = "Body 2 segment"; var body1 = "Body 3 segment";
var mailto_link = 'mailto:'+email+'?subject='+subject+'&body=Line1: '+body1+' Line2: '+body2+' Line3: '+body3;
I want it to output like this:
Line1: Body 1 segment Line2: Body 2 segment Line3: Body 3 segment
11:22 pm on Feb 4, 2012 (gmt 0)
You should probably be url encoding (percent triplet) the parameter values, in which case the newline would be %0A (ascii 10) and carriage return %0D (ascii 13). I guess this will be down to the email client whether it is handled as expected.
12:17 am on Feb 5, 2012 (gmt 0)
var mailto_link = 'mailto:'+email+'?subject='+subject+'&body=%0ALine1: '+body1+' %0ALine2: '+body2+' %0ALine3: '+body3;
Or, instead of %0A I could use %0D instead?
1:04 am on Feb 5, 2012 (gmt 0)
Yes. That works for me on Windows with Thunderbird. Just the newline (LineFeed / %0A) character should be sufficient I would have thought.
5:39 pm on Feb 6, 2012 (gmt 0)
Strange. I tried that; but now it doesn't even send an email. Although I think I have bigger problems because I need to be able to change the subject each time.
6:21 pm on Feb 6, 2012 (gmt 0)
...it doesn't even send an email.
Doesn't send? Or doesn't open the email client?
Just to add, if this is used in an HTML document then the ampersand should be entity encoded as &
12:29 am on Feb 7, 2012 (gmt 0)
It doesn't send the message (no message received) and it doesn't even open the email client to send the message. What about with a "?", do I need to make that different like the &?
7:39 am on Feb 7, 2012 (gmt 0)
You don't need to encode the "?".
Can you post the exact code you are using?
11:09 pm on Feb 7, 2012 (gmt 0)
The "valid_email" is the first part of my email address so I changed that.