Question

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?

Was it helpful?

Solution

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>

OTHER TIPS

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');
        }
    });
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top