1

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?

000
  • 26,951
  • 10
  • 71
  • 101
Alen
  • 897
  • 2
  • 15
  • 33
  • 1
    Check this SO question for details about this http://stackoverflow.com/questions/4782068/can-i-set-subject-content-of-email-with-using-mailto – adear11 Sep 11 '13 at 20:29

2 Answers2

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
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:

http://jsfiddle.net/Vxgmw/

<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