My organisation uses a label sharing add-in to share emails across our Gmail accounts.
We want to create a way to be able to link to a specific email that, through the above add-in, we know exists in all users' accounts. We've identified that an email's MessageID is a unique identifier, and that GMail allows the MessageID as a search parameter.
This means we can create a URL that will open GMail into a search query for a MessageID that will only have 1 result. The user can then click this one result to see the email. It's not as nice as launching straight into the email in question but it's good enough.
In Gmail, the MessageID of an email can be obtained when inside an email by clicking the 3 dots top right, clicking < > Show original
, it is then displayed in the page that shows (see screenshot below). We would then manually copy this (I assume automating this part of the process isn't feasible via. TextBlaze)
I would like a TextBlaze command that displays an input box for a user to paste in a MessageID which takes the form <randomidstring@url.com>
and convert this into the search query URL like this:
https://mail.google.com/mail/u/0/#search/rfc822msgid%3A%3Crandomidstring%40url.com%3E
I have tried using AI to create a snippet but without success, any pointers would be appreciated.
Screenshot:
Hi @Martin_Hill Apologies for the delayed response!
I assume you want a snippet like this so that it can be directly triggered into the browser address bar by typing tb<space><snippet-shortcut>
:
Note the key part is the urlencode function which correctly encodes the angle brackets so they're valid in the URL.
You can also make it so that the message ID is pulled directly from an open Gmail page - so the user doesn't need to copy/paste it:
Hi Gaurang, thanks very much for this. The second snippet was exactly what I was after, better than I had hoped was possible in fact. BUT, it worked at first, then I don't know what changed, but now it doesn't? Here's what I'm getting when running it:
[Error - No match found for selector: ".message_id".]https://mail.google.com/mail/u/0/#search/rfc822msgid%3A"Error%3A%20No%20match%20found%20for%20selector%3A%20\".message_id\"."
In case it's relevant, I run my Gmail installed as an app, i.e. the window it's in has no URL bar visible. So I was running the snippet from the search bar (with an individual email opened). I also added some key strokes to the snippet to copy it to the clipboard (is there another way?) and then mimic Esc keypress to clear the search bar. I removed those when it stopped working as a troubleshooting attempt, but no joy. Any thoughts?
Great to hear that! Regarding the error, I see the message is:
Error - No match found for selector: ".message_id".
This suggests that the "Original message" tab is not open anywhere in your browser window. I am referring to the page that opens when you do this:
In Gmail, the MessageID of an email can be obtained when inside an email by clicking the 3 dots top right, clicking < > Show original
Did you close it by accident while running the snippet? If not, a short video recording showing the issue would be great. You can also email it to me at gaurang@blaze.today
Ah, I see. I didn't realise the 'Show original' had to be open whilst running the snippet. I was just running it from within the email message I wanted to link to. With the 'Show original' open it does indeed work as expected.
Is there any way to do it without having to open the 'Show original', or automate opening of the 'Show original' window?
Alternatively, if it's not possible, when the snippet errors can a note pop up informing the user they need to "Click 3 dots > <>Show original before running this snippet" ?
Is there any way to do it without having to open the 'Show original', or automate opening of the 'Show original' window?
It's not possible to do it without opening the "Show original" window, unless - I'm not sure about this - we use the Gmail API.
It's also not possible to open the "Show original" window and then read its contents from within the same running snippet. This is something we want to support in the future, but for now, it might be simpler to open the original window manually.
can a note pop up informing the user they need to
Yes, we can show an error like so:
Although it will look a bit weird as it thinks we're trying to open a URL, because we typed it in the omnibox:
Thanks for the update Gaurang, what you've provided is still much better than the manual way I was doing it.