42

How to force web-browser to navigate to Gmail and create (if logged in) new letter with filled in field 'To' on click on mailto:SomeMail@blabla.example?

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Sergey Metlov
  • 25,747
  • 28
  • 93
  • 153

6 Answers6

96

There's a Greasemonkey script. The compose URL is:

https://mail.google.com/mail/?view=cm&fs=1&to=email@domain.example

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Vlad
  • 10,602
  • 2
  • 36
  • 38
  • 13
    Great answer! Looking at the source I see that `cc`, `su` (subject), and `body` are also available as URL parameters. – Benjamin Atkin Aug 08 '11 at 21:22
  • 1
    Hi Vlad, Can we attach documents to the same link you have given? I want to open mail composer with attached documents. – Poorav Solanki Mar 09 '17 at 06:05
  • Hello, link works but default signature not showing. Signature works at gmail.com but not when opening with the custom link. Any idea why? – karlosuccess Mar 09 '22 at 18:51
19
<a href="https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=someone@example.com" target="_blank">Title</a>
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Manjeet Kumar Nai
  • 1,382
  • 1
  • 13
  • 16
11

mailto is one of many URL Protocols and it's a way for commands to exit the browser and interact with other applications. I can't find a good site defining what a URL Protocol is but here's how one is registered, it also describes how one is called: http://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx

As a web developer, you won't be able to twist mailto to do what you want on your site. You can use this link:

https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=target@email.example

Not suggested though. Anybody who clicks it needs to be signed into their gmail account (if they have one), but it technically works if the user has gmail and is signed in.

As a user, if you want other sites' mailto links to take you to gmail, then whatever browser you have is bound to have an extension or plug-in you can use that will manipulate mailto links to the link I gave you above.

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Corey Ogburn
  • 24,072
  • 31
  • 113
  • 188
  • I think *this* is what the asker wanted to know. I think it's fair to say it's not suggested. It's useful in some cases, though, because it can be a pain to get mailto: working properly. I agree that using a browser extension or operating system protocols is better in the long run, but it can be a nice option to have in settings for an online CRM app. Also depending on user feedback, the option might need to be extended to include google apps for domains and other email providers. – Benjamin Atkin Aug 08 '11 at 21:15
  • Ripped this from Craigslist: https://mail.google.com/mail/?view=cm&fs=1&to=kxps2-6529650434%40sale.craigslist.org&su=Mattress+and+gas+grill&body=%0A%0Ahttps%3A%2F%2Flosangeles.craigslist.org%2Fwst%2Fzip%2Fd%2Fmattress-and-gas-grill%2F6529650434.html%0A you can see how they set the "Subject" as "su" – chrisallick Mar 13 '18 at 22:50
8

To add Subject, Body, CC, and BCC, just add the parameters to the URL:

  • Carbon Copy (CC) is the parameter "cc"
  • Blind Carbon Copy (BCC) is the parameter "bcc"
  • Subject is the parameter "su"
  • Body is the parameter "body"

Example:

https://mail.google.com/mail/?view=cm&fs=1&to=someone@example.com&cc=someone@ola.example&bcc=someone.else@example.com&su=SUBJECT&body=BODY

Or:

<a href="https://mail.google.com/mail/?view=cm&fs=1&to=someone@example.com&cc=someone@ola.example&bcc=someone.else@example.com&su=SUBJECT&body=BODY" target="_blank">Mail Us</a>
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Derzu
  • 7,011
  • 3
  • 57
  • 60
2

Above works also works. I tried following link in my <a> tag. https://mail.google.com/mail/u/0/#inbox?compose=new

Bhagawat
  • 468
  • 4
  • 12