0
votes

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.

1

1 Answers

0
votes

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.