email link with body of email

This forum is for all Flare issues not related to any of the other categories.
Post Reply
devangee
Propeller Head
Posts: 31
Joined: Fri Aug 03, 2007 11:52 am

email link with body of email

Post 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?
Leon Descoteaux
Propeller Head
Posts: 29
Joined: Fri Jun 27, 2014 7:51 am

Re: email link with body of email

Post 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
Leon
formerly User crdmerge and crdmerge2
devangee
Propeller Head
Posts: 31
Joined: Fri Aug 03, 2007 11:52 am

Re: email link with body of email

Post 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.
JvdB
Propeller Head
Posts: 12
Joined: Fri Feb 28, 2020 2:05 am

Re: email link with body of email

Post 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>
Post Reply