I have a problem. I need to make a link, if user click on that link users native email client will open with predefined message, but user must be able to select receiver address. I'm aware of mailto command but I couldn't find a way to allow user to select his own receiver address. Can someone help me with this?
Asked
Active
Viewed 1,892 times
2 Answers
3
If you want to create default body copy without a default address you just ignore the address:
<a href="mailto:?body=This is the body copy.">Send email</a>

dev-null-dweller
- 29,274
- 3
- 65
- 85

Tim B
- 1,879
- 1
- 13
- 8
-
Also remember to urlencode your content before putting it in href. – dev-null-dweller Sep 11 '13 at 20:35
-
-
And don't forget that the number of characters for the body value is limited (afaik to 2000 characters) – flumingo Sep 15 '15 at 14:44
0
It's not clear what you want. Do you want the user to define the email in the browser or in their mail app? Here's a jsfiddle to show how to define it in the browser:
<p><input type="radio" name="email" value="support@apple.com" />Apple</p>
<p><input type="radio" name="email" value="support@microsoft.com" />Microsoft</p>
<p><input type="radio" name="email" value="dev.null@example.com" />Linux</p>
<p><input type="radio" name="email" value="other" />Other: <input type="text" name="other_email" /></p>
<p><pre id="mailto_link"></pre></p>
$(function() {
$(':radio[name=email]').on('change', function() {
if ($(this).val() == 'other') {
$('#mailto_link').text('mailto:'+$('input[name=other_email]').val()+'?this+is+the+predefined+message');
}
else {
$('#mailto_link').text('mailto:'+$(this).val()+'?this+is+the+predefined+message');
}
});
$('input[name=other_email]').on('keyup', function() {
if ($(':radio[name=email]:checked').val() == 'other') {
$('#mailto_link').text('mailto:'+$(this).val()+'?this+is+the+predefined+message');
}
});
});

000
- 26,951
- 10
- 71
- 101