Christian
Christian

Reputation: 13

Gmail - Link to Draft in non-conversation view

I am importing/creating drafts in Gmail using the Gmail API. After creation I'd like to redirect the user to the Gmail UI with the opened Draft in the composer window.

I made it work properly for https://mail.google.com/mail/#drafts?compose=[MESSAGE ID]. Other urls I found here also worked well. Gmail is doing some redirects and eventually the composer window is opened with the draft.

Now my issue:

If the user has not enabled "Conversation view" this will not work at all. The redirect will then result in https://mail.google.com/mail/u/0/#drafts?compose=new and only an empty, new composer window is shown and a new draft is created by the UI.

If I open the draft directly the ID-format is different. https://mail.google.com/mail/u/0/#drafts?compose=hJzgZpSqgLQcCWgZqnlNRzRBfMbjZVnZklzvcFxhQCdwT... and I have no idea if this format can be generated somehow.

Does anybody has an idea or experience to also make it work with this UI setting. How I can force Gmail to load the draft into the composer window?

Thanks in advance.

Upvotes: 0

Views: 456

Answers (2)

Mar Box
Mar Box

Reputation: 1

This appears to still be an issue the one solution I did find was that you can find your draft directly (even though it would be the last draft) and go through multiple accounts by redirecting to

https://accounts.google.com/AccountChooser?authuser={user account}&Email={email account}&continue=https://mail.google.com/mail/#search/rfc822msgid:CAMU-31NcJCVHyGNsAycRKfuS0nMonoaZ6wFMD90Sej996qjuPQ@mail.gmail.com

You need to get your message id toi replace the area from <> from your draft. So you'll have to create the draft first. Get the google message ID, then use that with messages/get to get the Global Message Id (also referred to as message id) and then use that with a search. At this point you'll open a page with a search to a single draft but it will not be opened. Your users will have to click on the one message. Unfortunately there does not seem to be a way to have the good way work for conversation view, and this way work for non.

I tried many different URLS and nothing worked. As noted in the original question, it might work that you could link to the full URL but I see no way to get that. If you spend long enough working with an email you'll even find that ID changes so they aren't even stable within a single day.

Another solution that could work is as explained:

https://mail.google.com/mail/u/0/#inbox/DRAFT_MESSAGE_ID

But as noted this does not open the draft on the first time you go there. It seems you have to travel to that link 2 times in a row to get the message to appear. I guess you could go to the page maybe inject some javascript to go to the page again but I don't know how to do that.

Upvotes: 0

Jose Vasquez
Jose Vasquez

Reputation: 1738

If you have Email Threading > Conversation View enabled

Make use of the following URL

https://mail.google.com/mail/u/0/#inbox?compose=DRAFT_MESSAGE_ID

If you have disabled the Email Threading > Conversation View option

Make use of the following URL

https://mail.google.com/mail/u/0/#inbox/DRAFT_MESSAGE_ID

Additional information

  • The main difference between them is that the first is treated as a conversation while the second example is not.
  • You can use #drafts instead of #inbox in the URL.
  • The number after .../mail/u/ is the session you have opened
  • You can retrieve the DRAFT_MESSAGE_ID by making a request to the API
  • You can approximately generate the compose ID by yourself, there are some examples out there (not recommended). I strongly recommend you to use the DRAFT_MESSAGE_ID instead.

Upvotes: 0

Related Questions