Create a Gmail share link
Asked Answered
D

3

3

I would like to put a button on my one page web application that allows a user to send a link through Gmail. I found that some websites such as addthis.com provide such a button, however this button automatically uses the link from the url bar. Since I have a one page web application the link in the url bar will always be the same. I need to be able to to put the link in the button myself (which is possible with, for example, the Facebook and Twitter share buttons).

How can I create a Gmail button that can be used to share a link?

Thank you.

Dartmouth answered 7/6, 2017 at 22:31 Comment(5)
Why not just get an image you want and link it via html like a regular link?Padus
That would be fine but what HTML code can I use to allow a user to send a link through Gmail? I am looking for something like this: <a href="mailto:?body=url-to-be-shared.com"></a>. But instead that this link opens Outlook it should open Gmail.Dartmouth
Try this: #17924036Lieu
Thanks, that seems to work great on a desktop. However it doesn't seem to work on a mobile phone. Does anyone have an idea what url I could use to share a link through Gmail using a mobile phone?Dartmouth
What if someone doesn't have gmail?Padus
W
9

On Button click write a function and do this inside the function

let url = 'https://mail.google.com/mail/?view=cm&fs=1&tf=1&to=&su=Your+Subject+here&body='+msgbody+'&ui=2&tf=1&pli=1';

window.open(url, 'sharer', 'toolbar=0,status=0,width=648,height=395');

The url will generate a link to open a gmail tab with auto filled subject and in in place of msgbody you can put your url you want to share.

Witchy answered 5/12, 2018 at 7:59 Comment(1)
is it possible to add an image to the body? thanksCarper
S
1

enter image description hereGmail Sharable Link Creator

Site Link: GmailLink.GitHub.io

Steps to Follow to generate the Link

  1. Get the Message ID Of Mail Thread (Mail > 3 dot menu in Right side (⋮) > Click on Show Original > See the MessageID).

  2. Copy the Message-Id

  3. Use the MessageId & click On Submit to generate the Mail Sharable Link.

Synchrocyclotron answered 17/5, 2020 at 9:35 Comment(0)
E
0

Try the official Google+ Share button. There's a field there where you'll specify the "URL to share". Since you're only using one URL, this might work in your favor. enter image description here

Encephalitis answered 8/6, 2017 at 9:57 Comment(1)
This Feature was deleted by googleRosenquist

© 2022 - 2024 — McMap. All rights reserved.