Home > Back-end >  GMAIL: How to open a Sent email in browser by URL if I know its id?
GMAIL: How to open a Sent email in browser by URL if I know its id?

Time:04-20

Shortly: How to open email in gmail if I know its id in new window?

Greetings. I get from GMAIL API the id of needed email. I want it to open in separate window by, for example, btn click in my add-on. What I know:

  • what using javascript code -window.location.href = to open url in new window.
  • You can open drafts using URL https://mail.google.com/mail/u/0/#drafts?compose=NeededID but it wont work with for example Sent emails

Any idea how the url should look like so that you can open the email in separate window in gmail.

CodePudding user response:

The answer was found, at least I think I found it . So here are steps , if you know messageId.

1)Need to make REST request to GMAIL API to get Id of the message. GET https://gmail.googleapis.com/gmail/v1/users/{userId}/messages/{id}
how to get Id of email
3) Put it this Id inside this URL and open it in browser https://mail.google.com/mail/u/0/#all/{IdWhatYouGotFromRequest}
4) ????
5) PROFIT

Example how it would open it How it would be opened

  • Related