How to Send Mail with a Subject Using a Mailto Url

Can I set subject/content of email using mailto:?

Yes, look all tips and tricks with mailto: http://www.angelfire.com/dc/html-webmaster/mailto.htm

mailto subject example:

<a href="mailto:no-one@snai1mai1.com?subject=free chocolate">example</a>

add original subject to mailto link

You would have to do it all pre-send. You could add dynamic parts/variables that would be set based on who you sent it to.

Most email service providers offer this service under the terms "merge tags", or "dynamic content". You could mimic this yourself if you have the serverside know how. Otherwise check out Mailchimp or Campaign Monitor (linked).

Set a mailto link with a subject containing an ampersand (&)

In order to get special/reserved characters into a URL, you must encode them - to get an & to work, it must be encoded to %26.

More details here: http://www.w3schools.com/tags/ref_urlencode.asp

Email button: subject and body text for mailto link

In almost every language (PowerShell is one exception), text strings are delimited by typewriter quotes (' and ") not typographic quotes (, , or ). You should replace your quotes like so:

onclick="window.location.href='mailto:me@any.com?subject=Request%20invite&body=Hallo%20you'"

The onclick attribute is written as a single string (delimited by double quotes) whose href whose value is a single string (delimited by single quotes) expressed as a URL-encoded query string.

Note also that you can’t rely on mailto links working unless users have configured a local email client correctly.

See the Mailto Wikipedia article and this related question for more information.

mailto link with HTML body

As you can see in RFC 6068, this is not possible at all:

The special <hfname> "body" indicates that the associated <hfvalue>
is the body of the message. The "body" field value is intended to
contain the content for the first text/plain body part of the
message. The "body" pseudo header field is primarily intended for
the generation of short text messages for automatic processing (such
as "subscribe" messages for mailing lists), not for general MIME
bodies.

mailto: subject= and body= support in email clients

The behavior varies by both email client and source application. Here's a likely enough example from my own system, using pjp's link.

<a href="mailto:me@somewhere.com?subject=Hello%20People">Send Mail</a>
  • Mailto link followed within Outlook client successfully fills subject
  • Mailto link followed in IE successfully fills subject for Outlook client
  • Mailto link followed in Firefox fails for same Outlook client (subject text remains part of "TO" field)

I tried the same link in HTML emails read by gmail and Yahoo web clients.

  • Gmail correctly opens a new message with desired subject
  • Yahoo pre-fills the subject, but truncates at the space ("Hello" only)

That much variation on just one computer makes embedded mailto tricky to use. I bet that's why many email newsletters provide a "View as a web page" link in the header.



Related Topics



Leave a reply



Submit