Reputation: 1002
When looking at a GMail message, the URL used to simply contain the message ID that I could then easily query with the GMail API.
E.g. when looking at an email, the URL was something like
https://mail.google.com/mail/u/1/#inbox/167d7bc198aa3059
This was convenient for development and debugging problems with specific emails. I could just make a call to get_user_message with 167d7bc198aa3059
But now, the same URL is expressed like this:
https://mail.google.com/mail/u/1/#inbox/WhctKJVJZkbrQVvLJqnhlZMQRckHrPbrhZMXXWzVswzckGCcRjQSZzjsPwcfhsDNXsFTDTG
How can I find back the message Id to query on my API from the new GMail URL format?
Or is there a simple encoding/decoding that transforms
WhctKJVJZkbrQVvLJqnhlZMQRckHrPbrhZMXXWzVswzckGCcRjQSZzjsPwcfhsDNXsFTDTG
into
167d7bc198aa3059
?
Upvotes: 10
Views: 1822
Reputation: 820
In the new Gmail
thread-id
document.querySelector('[data-legacy-thread-id]').getAttribute('data-legacy-thread-id')
message-id (when you enter an email)
document.querySelector('[data-message-id]').getAttribute('data-legacy-message-id')
You can get all emails list with google API
curl \
'https://www.googleapis.com/gmail/v1/users/userId/messages/id' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
Upvotes: 1
Reputation: 6791
You can use the following code in the console to obtain the message ID:
document.querySelector('[data-message-id]').getAttribute('data-legacy-message-id')
Or just inspect the DOM:
Upvotes: 9