How to open a draft created with Gmail API in browser?

心已入冬 提交于 2020-11-29 23:46:11

问题


Im trying to create a gmail draft using gmail API and open it in a new tab.

When i try to open a draft using the following url : https://mail.google.com/mail/u/0/#drafts/ draft id , from a external web it does not open the draft. Instead it lists the drafts. If i do the same in a Gmail tab it works as expected.

You can reproduce it following this steps

  1. Chose any draft and copy its message id , you can use this
  2. Create a url joining https://mail.google.com/mail/u/0/#drafts/ + the message id you got in the last step.
  3. Open a new tab in Chrome and paste it, it will send you to your draft list.
  4. If you paste the same url in the the same tab it will open the draft.

More information about the problem

It does not work with https://mail.google.com/mail/u/0/#drafts/?compose= neither

Chrome console throws this error when i try to open a draft from another tab console error

I noticed if you open a draft the url is like this one https://mail.google.com/mail/u/0/#drafts?compose=JHrtffLJpZXxNwzKGMhcjvjBrqfPRwKWvkvJbtWpRffXldzxkNQhmkkBWJsHPbdSPdDgBVKpHKZMNtCVFgXrhwMCVjCdCRqTLJhGvqrXNKFZmJDGZ , this url works also to open the draft editor from other tabs, but where does the compose value come from?

I know it is not a API error or problem but if somebody had the same problem and know any way to solve it i will apreciate.

So the question is, how can i create a url to open a gmail draft using Gmail API ?


回答1:


The way to make this url changed, now it works like this:

mail.google.com/mail/#inbox?compose=draft.message.id

If you list your drafts you get

{
  "drafts": [
    {
      "id": "r5632827412362757569",
      "message": {
        "id": "174f4fa0dd96af123",
        "threadId": "174f4f59344d6321"
      }
    }
  ],
  ...
}

So, to open this draft you need the following url :

mail.google.com/mail/#inbox?compose=174f4fa0dd96af123




回答2:


Your goal:

To be able to open a browser tab directly focused on a specific draft of your choosing, from the drafts in your mailbox. (Correct me if I'm wrong).

Background:

  1. You noticed that drafts have a "compose" parameter visible in the url when focused within the UI.
  2. The drafts resource doesn't include the "compose" parameter, so we can't get it from the API, and it also isn't equal to the draft id.

Conclusion:

Since the parameter needed is not publicly available via API, you can't achieve your goal at the moment. You can request the feature to Google directly by creating a "Feature Request" for the Gmail API. Here's the link Issue Tracker.



来源:https://stackoverflow.com/questions/64022899/how-to-open-a-draft-created-with-gmail-api-in-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!