2

I'm working on a chrome extension to add functionality to the Gmail message composer, and it requires either:

  • having a fixed Message-Id that won't change with draft updates (the API docs make it clear the Message-Id changes with every draft save, but maybe there's a way?)

Or

  • adding a custom header that will be included when the draft is sent.

Currently, my extension works by running in the gmail composer and replacing the standard Send button. When the user clicks my send button, I transform the message and update the draft raw message via the API. This is useful for manipulating the attachments. Then I send the message by simulating a click on the normal send button. My API changes to attachments, combined with changes in the web interface draft editor, are reflected in the sent message.

I've tried including a custom header in my drafts.update (raw) API call, and that actually does update the draft. (If I then send the draft using the API, the custom header is included in the outgoing message. However, then the web interface is left in a weird state because the draft was sent in the background using the API, while the web ui draft is still open.)

What I'd really like is to be able to add my custom header via the drafts API, and then send the message via the web interface but keep the custom header for the outgoing message. Is there any way to achieve this? Maybe through the drafts metadata endpoint?

I could also use the message-id header for my purposes, but I need to know what the final id will be before sending the message.

Andrew Goldberg
  • 185
  • 1
  • 9
  • Both the Drafts.Update call and the Messages.Send API take the same RFC822 formatted message. I don't know if sending the updated draft through the web will conserve your headers though, worth a shot as it likely uses the same Drafts.Send API which would. What are you trying to accomplish? – Grant Watters Mar 13 '17 at 03:59
  • Sending the draft with the API does keep my headers; however I'd like to actually do the send via the web interface, and in that case it seems the headers get ignored. – Andrew Goldberg Mar 13 '17 at 12:36
  • My ultimate goal is to have a unique id in the headers that can be mentioned in the body HTML. – Andrew Goldberg Mar 13 '17 at 12:36
  • I'm sure I don't understand your full scenario where you have to be viewing the email in the Gmail web client and creating/update the same response elsewhere. One thing you can try instead is to insert a hidden styled div that contains the info you need. More work than setting a header.. but the gmail client should keep it around. – Grant Watters Mar 15 '17 at 04:52

0 Answers0