Part of an app I'm working on creates links to messages in GMail using their message ID:
"https://mail.google.com/mail/u/0/#search/" + encodeURIComponent(`rfc822msgid:${interaction.messageId.replace(/(^<|>$)/g, "")}`)
Simple enough.
The problem comes when a user has multiple Google accounts, and the message they're opening does not belong to the currently logged in one: The link should open a search with only one result, if the user isn't logged in to the correct account, no message is displayed.
Is there any way to specify which email address to open the message with in the URL?
Something along the lines of https://mail.google.com/mail/u/0/[email protected]#search/rfc822msgid:[email protected]
Found an answer over on WebApps.
You can use the query string parameter authuser to specify an account to use with the URL:
authuser
https://mail.google.com/mail/u/[email protected]
or (using the URL from my question):
https://mail.google.com/mail/u/0/[email protected]#search/rfc822msgid:[email protected]
2.1m questions
2.1m answers
60 comments
56.9k users