Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Gmail message source, generate direct link

So using the gmail message source is it possible to generate, a link to the message/thread in GMail's own interface?

on http://productforums.google.com/forum/#!topic/gmail/goChl1gG0NQ they use the following

https://mail.google.com/mail/#all/<HexEncodeMessageID>

Is this related to the Message=ID header found in the mail's source?

Message-ID: <[email protected]>

The discussion Find Gmail url-IDs via IMAP seems to only give IMAP based solutions.

like image 347
arnonymous Avatar asked May 30 '13 03:05

arnonymous


People also ask

Does Gmail automatically hyperlink?

The URL won't hyperlink automatically, so you need to close out of the draft, then go back into it. At that point, it'll be hyperlinked. 4. Type the words you want to hyperlink somewhere within the URL.

How do I hyperlink a Gmail thread?

Click the link icon next to an individual email to create a share link for any message in Gmail. A link will be automatically created, which you can easily copy and paste using your clipboard.

How do you create a link that automatically opens a Compose email outlook?

In the message, select the text or picture that you want to display as the link. On the Insert tab, click Link or Hyperlink. Under Link to, click E-mail Address.


3 Answers

Here's an updated bookmarklet over what Benjamin Ziepert suggested. Basically with removed /u/0 part to make it a little more account-independent.

javascript:window.open("https://mail.google.com/mail/#search/rfc822msgid%3A" + encodeURIComponent(document.getElementsByClassName('message_id')[0].innerHTML.slice(4, -4)), "_self");

Usage: Save this link on your bookmarks bar. To get a direct link to a message, choose "Show original" on the dropdown for that message, and then click the bookmarklet on the new page that opens.

like image 143
Platform anthropocene Inc. Avatar answered Dec 16 '22 20:12

Platform anthropocene Inc.


The "HexEncodeMessageID" that you refer to (and that occurs in links such as https://mail.google.com/mail/#inbox/14197d2548c9da1a) is unfortunately different from the RFC822 message ID (which occurs in the source of the email).

I do not know of any way to get a direct link to an email using the RFC822 message ID, but it is possible to search for a particular RFC822 message ID in Gmail (see GMail doc):

in:anywhere rfc822msgid:[email protected]

You can turn this into a link:

https://mail.google.com/mail/#search/in%3Aanywhere+rfc822msgid%[email protected]

(Don't forget that the message id should be URL-encoded. You can also just type the search in your GMail and copy the resulting URL afterwards.)

The problem with this link is that it does not send you to the mail directly, but to a search result page with a single hit. But this might be good enough for some applications.

The advantage is: The RFC822 is the same in your account and in the account of the sender. So if you want to refer to a given email in an email/chat, you can provide this search link (assuming the recipient also uses GMail). With the "HexEncodeMessageID" this would not work, because it is different in every account (according to my own experiments).

One last thing: the link only works when you are already logged in.

like image 31
Dominique Unruh Avatar answered Dec 16 '22 21:12

Dominique Unruh


Update

This bookmarklet no longer works. See Benjamin Ziepert's update.

Original Answer

I decided to make a bookmarklet to help automate this.

javascript:window.location="https://gmail.com/#search/rfc822msgid:"+encodeURIComponent(window.document.body.innerHTML.match(/Message-ID: &lt;(.*)&gt;/i)[1])+"/"+encodeURIComponent(window.location.search.toString().slice(1).split('&').filter(function(x){return x.slice(0,3) == "th="})[0].slice(3));

Save this link on your bookmarks bar. To get a direct link to a message, choose "Show original" on the dropdown for that message, and then click the bookmarklet on the new page that opens.

If anyone has suggestions for a clean way to do this without having to click show original, I'm all ears.

like image 23
dta Avatar answered Dec 16 '22 20:12

dta