is there anyway that I can use "mailto" with empty recipient? I only want to supply the subject and the message body and then the user can write the to addresses on mail. I tried writing only a space but it didn't work.
-
When you say "didn't work", what do you mean? Does anything at all happen when you click on the link? And can you post the "a href" link you tested with?– Lasse V. KarlsenNov 20, 2009 at 9:09
-
Also, what mail application are you using?– Lasse V. KarlsenNov 20, 2009 at 9:10
-
1And thirdly, why do you want this anyway? Are you making a shortcut to send email to anyone? Usually you want people to send an email from a website to a specific mailbox, like a support mailbox or similar. What are you actually trying to implement here? I'm pretty sure most people that use email is clever enough to be able to start a new email by themselves. What problem are you trying to solve?– Lasse V. KarlsenNov 20, 2009 at 9:11
-
i meant the email application of the iphone couldn't be opened when i left the recipient empty. it s not a href; NSString *url = [NSString stringWithString: @"mailto: ?subject=Test&body=Test!"]; [[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];– xenepNov 20, 2009 at 9:19
-
i'm showing football news in my application and i want to add a share functionality to news.every news has a share button at the bottom and i want the mail application of iphone to be opened with news title as the subject and news as the message content when that share button is clicked. then user can write the to addresses to send.– xenepNov 20, 2009 at 9:24
3 Answers
This should do, I tested it.
mailto:?subject=your%20subject&body=your%20body
And as HTML with correct escaping of the ampersand:
<a href="mailto:?subject=your%20subject&body=your%20body">test</a>
-
1
-
@DigitalDesignDj No, that's a URL parameter, but your subject and message body will need to be URL encoded.– XyonJun 27, 2013 at 10:50
-
@Már Örlygsson see @Xyon's comment - you shouldn't escape the ampersand after
subject
because it's a URL parameter separator, not a literal ampersand. Jan 8, 2016 at 17:26 -
Nope, the example shows the URL as part of HTML code - and "&" is a reserved character in HTML and needs to be escaped. The code example is invalid HTML without & Jan 17, 2016 at 21:39
-
The above example will work without the & escaping - but only because current browsers adhere to the Robustness Principle and autocorrect this bad HTML. Jan 17, 2016 at 21:41
This should work..
<a href="mailto:?subject=My Subject">test</a>
-
3Of all the suggestions, this was one was the working for me. A lot of the other solutions are 5 years old.– afxjzsDec 10, 2014 at 16:55
I tried the accepted answer but it failed to launch an email when using Chrome. Using a %20
instead of a space worked though:
<a href="mailto:%20?subject=Wazzup&body=Yo">Send an Email</a>
-
This worked for me while the others weren't. I was using chrome and my default mail client was outlook 2013 desktop.– user967451Aug 31, 2015 at 19:00