Page 1 of 1

email link with body of email

Posted: Wed Oct 29, 2014 4:48 pm
by devangee
I'm trying to create an email link where the link of the email opens a new message with both the subject and body of the email completed?
I can only get the subject, but can't figure out how to get some text in the body of the email.

I've searched online for the code, and have added it in the text editor, but no of what I tried works.

Any suggestions?

Re: email link with body of email

Posted: Thu Oct 30, 2014 5:43 am
by Leon Descoteaux
A "mailto:" JavaScript file (which we called feedback_script.js) worked for us. The link in each topic or in a master page would look like this in the code:

Code: Select all

<script src="feedback_script.js" language="javascript" type="text/javascript" xmlns="http://www.w3.org/1999/xhtml"></script>
The contents of feedback_script.js would look like this:

Code: Select all

var mailSubject = 'Your Subject Line; 
var mailBody = '[Enter comments here] \n\nMy comments apply to this page: ' + location.href; 
var mailDisplay = 'Feedback on this page'; 
document.write( 
'<a href="mailto:yourdocteam@yourdomain.com' 
+ '?subject=' + escape(mailSubject) 
+ '&body=' + escape(mailBody) 
+ '">' + mailDisplay + '</a>');
The location.href pulls your topic's file name. The mailto: address would be a dedicated email address for receiving all comments.


Hope this helps

Re: email link with body of email

Posted: Thu Oct 30, 2014 10:46 am
by devangee
Thanks, I was hoping that there was some non-js way of doing this, since I have zero js experience.
I'll work with this and try to figure it out.

Re: email link with body of email

Posted: Mon May 17, 2021 3:58 am
by JvdB
Thanks, I was hoping that there was some non-js way of doing this, since I have zero js experience.
You have to ensure there are absolutely no spaces in your <a href> code - use %20 instead for spaces, and %0D for new lines. This coding worked for me:

<a href="mailto:support@yourcompany.com?subject=This%20is%20the%20Subject&Body=Hello,%0DMy%20account%20username%20is:%0DPlease%20suspend%20the%20following%20sub-accounts:%0D%0D%0D%0D%0DI%20understand%20that%20Service%20Charges%20will%20continue%20for%20these%20sub-accounts.%0DPlease%20reply%20to%20this%20email%20to%20notify%20me%20when%20the%20sub-accounts%20are%20suspended.%0D%0DKind%20regards,%0D%0D">Your link text</a>