TIP: Get a direct link to an email in Gmail, to put in Asana

Here is a trick I use quite a bit and wanted to share!

:sparkles:Get a (semi) direct link to any email within Gmail, to paste in Asana. :sparkles:

Great for those of us working with people outside of Asana who still use email more than we would like them to. Pasting this link into Asana tasks saves so much time digging through email to find it again in the future!

  • Create a new bookmark in your browser
  • Paste this javascript code into the URL field
  • Name the bookmark whatever you want. I named mine :link::arrow_right::e-mail:
  • Navigate to any email you want in Gmail
  • Click the bookmarklet you created
  • It will save the URL into your clipboard
  • Paste the URL wherever you want (like into Asana!)
  • Quickly find the email in the future by clicking that link
Copy this javascript

javascript:(function()%7Basync function copyPermalink() %7Btry %7BsearchURL %3D ‘https%3A%2F%2Fmail.google.com%2Fmail%2Fu%2F0%2F%23search%2Fmsgid%253A’%3BmessageId %3D document.querySelector(‘div%5Bdata-message-id%5D’).getAttribute(‘data-message-id’).substring(7)%3Bawait navigator.clipboard.writeText(searchURL %2B messageId)%3Bconsole.log(‘Mail message permalink copied to clipboard’)%3B%7D catch (err) %7Bconsole.error('Failed to copy%3A '%2C err)%3B%7D%7DcopyPermalink()%7D)()

Some things to note:

  • Only works within Gmail.
  • This link will only work for YOU. Anyone else clicking this link will not find the same email in their own inbox.
  • The link is not a true direct link but creates a custom search that will return only that email as the result.
  • I did not write this script and I forgot where I originally found it!

Thanks for sharing this tip, @Dyani ! :clap:

@Dyani, This looks like a great tip but they javascript appears with characters like %7B instead of { and even after I make those substitutions I think there’s a syntax error. Any chance you could try pasting differently here so the characters don’t appear encoded? Maybe using code/prerformatted text feature in this Discourse editor (</>)?

Thanks,

larry

Oh no! I can paste it again but the characters you see here are exactly what I see in my bookmarklet, and I do not get any errors. So sorry! Hope this works for you. If it helps I’m using Chrome browser.

javascript:(function()%7Basync function copyPermalink() %7Btry %7BsearchURL %3D 'https%3A%2F%2Fmail.google.com%2Fmail%2Fu%2F0%2F%23search%2Fmsgid%253A'%3BmessageId %3D document.querySelector('div%5Bdata-message-id%5D').getAttribute('data-message-id').substring(7)%3Bawait navigator.clipboard.writeText(searchURL %2B messageId)%3Bconsole.log('Mail message permalink copied to clipboard')%3B%7D catch (err) %7Bconsole.error('Failed to copy%3A '%2C err)%3B%7D%7DcopyPermalink()%7D)()
1 Like

Thanks! I tried it again and this time it worked with copy/paste of your latest code!

I might have screwed something up. Was using Chrome browser both times, first on Mac then on Windows, but working now and handy–thanks!!

Larry

Hooray! Glad it worked that time.

1 Like

Hello all.
If you are using Chrome I created a free extension that does exactly that. You can also give the link to anyone that is in CC and it will work also for them: Gmail message URL - Chrome Web Store

1 Like