TransWikia.com

How do I link to a specific gmail search, google document etc on the correct google apps domain?

Web Applications Asked by Craig Ringer on February 28, 2021

I want to provide links to specific GMail folders, GMail messages, Google Drive items etc on a company webpage.

Users may have multiple Google accounts and it is not guaranteed that their primary / default account is the company account.

You’d expect this to be trivial and well documented, but … not so much. Google multi-account support uses URLs with /u/2 (or similar) to differentiate users by login ordinal position in the current session. These links break if the user logs out of an account then back in and they cannot be shared correctly between users.

Google accounts have the seemingly undocumented feature of supporting /[email protected] links which work but require a fully qualified user account. I could not find any documentation on it, nor any listing of supported paramters, and my guesses did not turn up any obvious “authdomain” type links that’d pick the currently logged in user matching the domain-part.

The redirect mechanism used by Google for subdomains does not appear to work for gmail links. You can’t take a link to https://mail.google.com/mail/u/1/#search/rfc822msgid%xxxxx%40mydomain.com and massage it into https://mail.mydomain.com/mail/u/#search/rfc822msgid%xxxxx%40mydomain.com or variants I tried with /u? etc. You’ll get an error like

Secure Connection Failed

An error occurred during a connection to mail.mydomain.com. PR_END_OF_FILE_ERROR

(Firefox)

This site can’t be reached

mail.mydomain.com unexpectedly closed the connection.

(Chrome)

So all in all, it’s ghastly. Not to mention that GMail searches to specific messages or threads are already painful; you have to “view source” because you can’t customise the headers shown, then hand-concoct a rfc822msgid:THE_MSGID_HERE msgid search.

Am I missing some simple sane way to just send a link that’ll take the recipient to a specific label, mailbox, message ID, search, etc?

One Answer

The two best options I've concocted so far, given a link to a msgid search with original URL

https://mail.google.com/mail/u/2/#search/rfc822msgid%3AXXXXXXXXXX%40MYDOMAIN.com

are:

Use a http-only redirect link and remove the user-id-enumerator

https://mail.google.com/mail/u/2/#search/rfc822msgid%3AXXXXXXXXXX%40MYDOMAIN.com
        ^^^^^^^^^^^^^^^     ^^^^^
        mail.mydomain.com   delete

https://mail.mydomain.com/mail#search/rfc822msgid%3AXXXXXXXXXX%40MYDOMAIN.com

Redirect via the Google account-chooser

Strip the user qualifier from the URL, and use the Google Account selector redirector for Google Apps at https://admin.google.com/ (but this may only work for admin accounts?)

https://mail.google.com/mail/u/2/#search/rfc822msgid%3AXXXXXXXXXX%40MYDOMAIN.com
                            ^^^^^
                            delete

then url-escape and prefix:

https://admin.google.com/ac/accountchooser?continue=https://mail.google.com/mail#search/rfc822msgid%3AXXXXXXXXXX%40MYDOMAIN.com

Frankly this seems utterly ridiculous. Is there some sane sensible way to do this that doesn't require mangling URLs in undocumented might-break-tomorrow-if-Google-feels-like-it ways?

Answered by Craig Ringer on February 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP