Industry guru Dave Taylor offers tech support on technical and business topics, including iPhone, iPod, Microsoft Windows, Sony PSP, cellphones, online advertising, CSS, Web design, business, Unix, Linux, SEO, Mac OS X, and shell script programming.     


Can I have a mailto link specify a subject and body?

Dave, I have a email link on a web page. Set so when you click it, the email opens with the address and subject line populated. I want to have the cursor OR Hello show up in the Body of the email. I am told 'ONLY' with forms but I am sure I did this years ago. Here is what I have so far:

      "mailto:me@my-addr.com?Subject=Dear Kirk"

Do you know the code to finish it off?


Dave's Answer:

First off, I have two articles worth reading in this regard: Avoid spam by omitting mailto links and hiding email addresses in HTML forms.

If you still want to use a mailto: link, then it turns out that there's quite a rich language of different options you can specify to get the mailto link to work just as you desire.

According to what I found out about mailto links, you can specify more than one recipient by listing them as a comma-separated list (skip spaces, though), like this: mailto:joe@hisaddr.com,sue@heraddr.com,mary@heraddr.com. Easily done.

Now, for anything that would be passing additional information, you need to use the form ?name=value and if you specify more than one variable, you need to separate them with &, just as if you were specifying a method="get" form, actually.

So, to specify the subject, you already know that you use subject=something, but you can also specify the "Cc" or "Bcc" recipients with, logically enough, cc=some@addr.com, or bcc=someone@else.com.

Finally, and this is what you asked about in the first place, to specify the body of the message, use body=. In fact, you can apparently specify more than one line of the body by using body= more than one time in the URL. So, putting it all together:

mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here
Try that, see how it works for you!


More Useful HTML, JavaScript and Web Site Programming Articles:
✔   How to Create Predefined Google Image Search Links?
Thanks for the Amazon URL [see Creating Amazon Search Links]. That worked beautifully. In fact, I sent you $5.00 for coffee in thanks....
✔   Can I embed a Facebook search box on my blog site?
I've seen your articles about how to add a Twitter or Google search box on a Web page, but I have a tougher...
✔   Can I use CSS for drop shadows on my blog?
I want to give my site a bit of a facelift and add some neat graphical elements. One of which is drop shadows....
✔   How can I embed interactive photo panoramas on my site/blog?
I read through your blog entry about how to take panoramic photos with iOS 6 and an iPhone 5 and got enthused. I've...
✔   How can I create a Twitter search URL shortcut?
I'd like to add a few Twitter search links to my Web site. Is that possible, or does Twitter prohibit this sort of...

Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
    Enter your name: and your email addr:  





Categorized: HTML, JavaScript and Web Site Programming   (Article 3911, Written by )
Tagged: email link, mailto, mailto link
Previous: Why is my HTML email all messed up?
Next: Can You Google "Dell Inspirion laptop" for me?




Reader Comments To Date: 56

Amit Dua said, on September 17, 2005 4:07 PM:

Thanks for the useful information. But here I want to ask one more question. While mentioning "body=" I want to change the line. I used br tag of html for it but instead of breaking the line, the tag is displayed as it is. Is there any method to break the line while using "body="

Dave Taylor said, on September 17, 2005 9:50 PM:

Amit, try using more than one body attribute, as shown in the very last example. It should let you break it into multiple lines. As you've found, you can't slip HTML into it, though, or you'll get the HTML source itself in the resultant message.

Arun said, on October 19, 2005 8:14 PM:

Hi Dave,

I hav ea small problem with the mailto link. How can I make the body content to be bold. Can you help me please.

Thanks.
Arun

Dave Taylor said, on October 19, 2005 10:35 PM:

Don't believe you can do that, Arun. Sorry.

Arun said, on October 20, 2005 9:23 PM:

oops!... :(

Anyway. Thanks for the help Dave. :)

Regards,
Arun

Elise said, on November 11, 2005 12:39 AM:

I'm trying to use multiple "body=" tags to break up the text but I always only get the text of the last one to appear in the email. What's wrong?

Dave Taylor said, on November 11, 2005 7:05 AM:

I think that multiple body= attributes is going to be supported by some Web browsers / email programs, but not others. I'd either experiment with more browser/OS/email combinations or just figure out how to have one really long body= attribute. Good luck!

alan said, on November 30, 2005 10:02 PM:

%0A == line break in a mailto link

example HREF:

mailto:addy@gmail.com?subject=Some Kind Of Subject&body=Here is my email body and %0Aa %0Afew %0Aline %0Abreaks.

Ryan said, on July 28, 2006 1:36 PM:

Thank you, Alan, %0A works just fine to break the body into multiple lines of text in a mailto command.

Rawd said, on November 7, 2006 6:14 PM:

I have this mailto link that I'm trying to use:

and in the resulting Thunderbird compose msg window I get the output a) in the TO: address field, b) in the CC: adress field and c) in the msg body:

a) someone@someadd.com
b)someoneelse"@someotheradd.com?subject=some subject?body=Hello+you!
c)Thanks for0%Anice0�������������������������

Lauren said, on January 27, 2007 7:36 AM:

Thank you! very well explained and functional!

Mike M said, on January 31, 2007 2:43 PM:

This doesnt seem to work in IE7. What is the deal with IE7, is this a known problem, and is there a fix? please help!

Mathan said, on March 1, 2007 6:57 PM:

Sir,

How can i use charchetr "&" inside body?

If i use inside the body , It will take automatically as separator.

Harshad said, on March 13, 2007 1:30 AM:

I have to insert a URL in the body of a mail using mailto tag. What I am getting is just the plain text and not the hyperlink in the body.
Are there any attributes for this in the bosy tag?
can you help me with this?

Thanks.

Adam said, on March 29, 2007 12:19 PM:

using extra body tags doesn't work to create new lines for me on Mac Mail program

chaitanya said, on June 1, 2007 3:31 AM:

hi,
i am using mailto:someone@somewhere.com?Subject=something

While this seems to work fine for mail editors such as outlook the subject doesn't get recognized in gmail or yahoo.is there a work around??

Thanks,
Chaitanya

karthik said, on October 4, 2007 3:32 AM:

Hi,

I need to display the test within "" inside the body of the mail using mailto tag..


can you help me..

mvdv said, on February 26, 2008 2:56 AM:

I see a lot of questions concerning sneaking HTML into the mail, for example hyperlinks and making text bold. I'd say that this is by defintion impossible, because you're making a TEXT email. No mark-up whatso-ever...

Ronaldo said, on April 30, 2008 11:42 AM:

Hi! Can you please help me. I need to pass the body of mailto: from a textbox. Is this possible? I'm using ASP.Net. Can you please send me the code if possible. Thank you so much in advance.

vinod said, on May 9, 2008 1:04 AM:

I have to insert a URL in the body of a mail using mailto tag. What I am getting is just the plain text and not the hyperlink in the body.

Aj said, on May 23, 2008 11:44 AM:

Hi,

Is this format supposed to work for Macs?

thanks,
Aju

Beth said, on November 21, 2008 7:57 AM:

From the article (and comments abound) I was able to create a mailto: link that works perfectly for our function! Terrific advice! Will be back in the future.

Richard Hefter said, on February 10, 2009 10:52 AM:

Hello,
Can you control the position of the cursor in Microsoft Outlook/express via mailto:

Toan Duong said, on February 22, 2009 6:04 PM:

For some reason

i have a few email links

yet some works and some don't, they're just plain text

why is this so?

Shiva said, on March 18, 2009 7:45 AM:

Hi, This funcion is not working in IE7 at all. Its just displaying the email id. The subject and the body is not displayed. Is this a known problem, and is there a fix? please help! Urgent

Cheryl said, on April 10, 2009 8:52 AM:

THANK YOU for the %0A code to be used in the mailto link!!! It worked great! I had been searching for this solution for hours!

dave said, on April 27, 2009 11:09 PM:

Hi dave taylor,

I have a problem in mailto reply. When I click on a link to send email through mailto then I need some information populated in body field which is not properly display in formatted. What should I do. I need to show body text with formatted text. Please if you have a answer then let me know.

Thanks..

Princy Khandelwal said, on June 17, 2009 6:09 AM:

How to format the body message using mailto like underline and making the text bold

miro lago said, on July 17, 2009 6:55 AM:

As I found out html tags within body attribute works well with Mozilla Thunderbird but not with Outlook.

Ramana.PV said, on July 30, 2009 7:15 AM:

How can we add attachments to mailto tag

Thanks,
Ramana.PV

John said, on August 25, 2009 12:01 PM:

I have a "canned" email as a hyperlink in Excel. The problem I have now is "the powers that be" want a change to the canned email. There are many carriage returns and a large boby with an additional signature block at the bottom. Excel will only allow a certain amount of characters in the body leaving me with half a message.

How can I get my whole message in the body?


John.

nicole tan said, on March 26, 2010 4:46 AM:

TQVM. It worked great. :D

urmila said, on April 16, 2010 5:16 AM:

hello...
in mailto option in html,visitors can alter the address,body etc...how can we avoid that?

Dave Taylor said, on April 16, 2010 8:34 AM:

Urmila, you can't. The only way you can guarantee that the email subject, etc., isn't modified is to create an HTML form and hide that content from the visitor, as I do with the "submit a question" form here on this site.

Jade said, on April 21, 2010 4:27 PM:

Thanks so much for this info! I randomly found it via Google search and it was exactly what I needed. Cheers!!

John said, on May 25, 2010 1:38 PM:

Your article was very helpful in getting my initial problem solved, but...

I use Gmail as my mail client. When I submit the form, it opens up Gmail in another tab and the original form page goes to the "about:blank" page. Can I prevent this, or more preferably, can I have it go to a confirmation page? If so, how? I'm not sure this is a problem with non-web based mail clients, but I don't have a way to test that at the moment.

Matthew said, on August 4, 2010 6:36 AM:

Thank you for sharing this article and how to do line breaks in the body section.

%0A did the trick nicely!

Cheers! :)

Rob Honeyman said, on August 10, 2010 6:13 PM:

Do you know if i can link the subject line to a cell? I wanted to be able to use a different subject line by controlling what certain cell contains

Thanks Rob

Michael said, on September 8, 2010 11:31 AM:

Is there a way to add an image to the email? Or make a request to the system to open the photo album on the way to the email composition form?

bob said, on November 17, 2010 6:08 PM:

%26 can be used to put & inside the body.

Hemal Shah said, on December 4, 2010 1:47 AM:

Thanks for this information. Addition of CC and BCC was a great input; solves my problem :)

JP said, on December 22, 2010 7:06 PM:

Hi,

Thanks for the great info. Now I'm trying to have a body content that has about 2,200 characters (after converting spaces and paragraphs into %20 and %A0) but the link is not working. It seems like there is an upper limit on the length for the body field. Does anyone know what is the length? And better yet, does anyone know how to avoid this limit?

Thanks,
JP

Dave Taylor said, on December 25, 2010 10:58 AM:

JP, I think you're pushing the envelope there. The maximum theoretical length of a URL is 2048 characters, according the specs I've read. However, many Web browsers actually implement a shorter length and I know that it used to be 1024 total characters, including the "http" and all that. Not a ton of space. If you're trying to send 2200 characters, I suggest you look at a Method=POST style CGI form instead: then there'll be no size limitations at all.

Here Iam said, on February 9, 2011 5:34 AM:

Hi,
I want to see only the text assigned to the url to be displayed, wen i click .

for eg:-
javascript:void(window.location.href='mailto:?Subject=hello&body=Click Here ')

When the above line of code is executed, it should open outlook /email displaying only " Click Here" and on clicking the specified url should open.

Thanks,

Larry said, on August 14, 2011 10:28 AM:

I have no idea on any of that but could someone help me. I have firefox and enabled the mailto: to yahoo mail. When I click a email link it opens in yahoo. But the subject is in the to: spot along with the address. The subject is empty. I have no idea what to do to fix this and been searching the web a few weeks hoping to find something. Is annoying having to copy and past everything in the right spots. Any help in the right direction would be greatly appreciated. Thanks!

stevee said, on November 2, 2011 2:14 PM:

use %26 to insert the & symbol with it not separating the email link.

Shane said, on November 10, 2011 8:17 AM:

I have tried this backwards and forwards, but it does not seem like the subject line can be populated on the iphone using the standard mailto:email@email?subject=Subject of email method. Has anyone else ran into this? I just need to get a subject line pre-populated, but do not want to mess with controls etc.

Thanks!

Frances said, on January 15, 2012 3:44 PM:

Position Body=& cc=& bcc=

When I click on a mailto link from outside a website it generates a "google search" for the terms shown above. A gmail form does open with the address in too but in the back ground. Why does the email not open in the forground and why does the google search happen? Noticed this happening with other sites too and not small ones, even major business services which should have thier act together and have things arranged to facilitate communication with their customers not cause them to scratch their heads wondering what is going on.

Priti said, on January 17, 2012 4:46 AM:

Hi, I have been used %0A for line break it works for mail client like gmail and outlook, but its not working with default yahoo mail client.

Julia said, on January 30, 2012 10:37 AM:

Hello, this link to create a pre-populated email message with the name, subject and body works, great, but what if i need to insert a hyperlink in my text in the body, for example by body reads, please click here to read the full article? How would i put in the hyperlink in the code to create the hyperlink.

mi-go said, on February 3, 2012 1:15 AM:

@Priti
Just try "", it works on default iPad mail app.

mi-go said, on February 3, 2012 1:18 AM:

Sorry, again...
@Priti
Just try a BR html code, it works on default iPad mail app.

ravnesh said, on February 27, 2012 4:45 AM:

hi all
how can we values extracted from the vb code and put it into mailto body[im using asp.net programming]

any idea????

thanks

ravnesh said, on February 27, 2012 4:18 PM:

iam getting data from database and want it to display in outlook mail[body].

any solution!!!!

Gulshan kumar said, on November 12, 2012 10:44 PM:

This is the best example for mailto: with cc, bcc, subject, & body elements...

http://www.w3schools.com/html/tryit.asp?filename=tryhtml_mailto2

Ichinisan said, on November 19, 2012 11:52 AM:

The author of this article should update it to mention that "%0A" is the preferred way to add line-breaks.

There are clearly browser compatibility issues when you use multiple "body=" statements. It's probably a fluke that it works at all in any browser.

Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you, Dave, for all your helpful information by buying you a cup of coffee!

I do have a comment, now that you mention it!











I will never send you any unsolicited email. Ever.






Check This Out Too...

 
Look for Answers
Need Help? Ask Dave Taylor!


Follow Me on Pinterest

Find Me on Google+
ADT on G+
© 2002 - 2013 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site. Further, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site. My lawyer says "Thanks".
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.