How to Share a Gmail Link

By Neal Grosskopf, Software Engineering Director

Published: August 3, 2020

In a hurry? Skip to the solution »

How much time have you wasted digging through your inbox to find an email? I bet the answer is a lot. But what if there was a way to share emails in Gmail with just a link? Well, I’ve discovered a solution that may solve all your problems. (Well, at least this one.) 

Backstory

At Envano, we use Google’s G Suite platform for all of our needs, such as scheduling meetings, reading emails and collaborating on documents. It’s a great tool, but a common problem we run into is referencing and sharing links to email threads with each other outside of Gmail.

Some examples of the issues we’ve run into when needing to share a Gmail link are:

  • Google calendar invites where we want attendees to review topics outlined in an email
  • Google docs for collaboration where a specific email is referenced
  • Conversations within our project management software (outside of the Google ecosystem) where a specific email is referenced

Usually, what happens in these situations is one person will say, “find the email with the subject line: fw: re: project update” and then everyone will attempt to find that email on their computer to varying degrees of success. This results in wasted time and effort.

To me, it seemed like a simple problem to fix, as Gmail already supports linking to emails in the tasks sidebar. Additionally, an email can be linked to but that link will only work for the person who copied it from their address bar.

The Solution

Drag the link below to your bookmark bar in your preferred browser. I recommend using Chrome or Firefox as both make it easy to drag the link.

Get Gmail URL

Once you’ve added the link above to your bookmark bar, simply visit a specific email within Gmail and click the bookmark. This will open the “original message” window. After that, click the bookmark a second time to open a link straight to the email you’d like to link to. After that, you can then share this link with anyone on the email thread. When they click the link, they should be able to view the email thread.

How It Works

The key piece of information that solves this issue is something in Gmail called rfc822msgid. RFC 822 is an old email standard dating back to the 1980s which defined how emails should be structured. Msgid or message ID is presumably a unique identifier for emails. This is likely what Gmail uses to keep emails threaded together.

Each email you send and receive has a rfc822msgid attached to it. Once you determine what the rfc822msgid value is, you can search your inbox for any emails with that ID. If you scroll all the way to the bottom of this list of Gmail search filters, rfc822msgid shows up as an option.

For instance, here’s a msgid for one of my emails: 

CAEphR5L+mD3eYDskXTh3M0tns2GHWd3xVa85ftyYmqvqCh0rRA@mail.gmail.com

Here’s that same email entered as a search query in Gmail:

https://mail.google.com/mail/u/0/#search/rfc822msgid%3ACAEphR5L%2BmD3eYDskXTh3M0tns2GHWd3xVa85ftyYmqvqCh0rRA%40mail.gmail.com

Automating the Acquisition of rfc822msgid

One problem with using this technique is it’s tedious extracting this information from Gmail. For instance, the steps involved require that you click into the email, view the original source of the email, copy the rfc822msgid, paste it into a crafted search and finally share that URL.

Because this is so clunky, I created a bookmarklet to automate this so it only requires two clicks! Bookmarklets are Javascript commands that can be run from your bookmark bar. Think of them as browser extensions before those formerly existed.

The first part of this bookmarklet acquires the GM_ID_KEY which is a Javascript variable Gmail uses to identify a specific email. This is used to pop open the “show original” email tab as it contains this in the URL of that page.

Once that tab is open, the next piece of Javascript grabs the rfc822msgid from the “show original” tab and opens that in a new window. Once that finishes, you can simply copy and and paste the URL from the address bar into your desired location.

The bookmarklet Javascript looks like the following:

javascript: (function() {
    if (typeof GM_ID_KEY != "undefined") {
        javascript: window.open("https://mail.google.com/mail/u/0?ik=" + GM_ID_KEY + "&view=om&permmsgid=" + encodeURIComponent(document.getElementsByClassName('adn')[0].getAttribute('data-message-id').replace("#", "")), "_new")
    }
    else {
        javascript: window.open("https://mail.google.com/mail/#search/rfc822msgid%3A" + encodeURIComponent(document.getElementsByClassName('message_id')[0].innerHTML.slice(4, -4)), "_self");
    }
})()
Yearning for more things digital marketing? Sign up for our newsletter, and we'll pop up in your inbox once a month.
Our newsletter, your inbox. Sign up.

Caveats

You can’t share an email with another person who wasn’t on the email thread. This would essentially be hacking if it worked that way. Also, the code I’ve written above may not always work as it relies on unsupported code used in Gmail (something that Google may change at any time).

Need us to walk you through the steps? Fill out our contact form and let’s chat!