0
votes

What I need is to detect if an email is sent using the "Schedule Send" tool in Gmail[1], via API or reading email headers (on the sender side/inbox).

Exactly the opposite scenario than here: As a recipient, is it possible to detect if an email was sent via Gmail's "Schedule Send" vs. "Send"?

In my experience, a scheduled email looks like a draft or a received email (with your address in the "from") for the API, and then, it raises an event when it is sent that adds the "SENT" label to the email. Is there a way to know that those are outgoing emails before the event?

[1] https://support.google.com/mail/answer/9214606?co=GENIE.Platform%3DDesktop&hl=en

1

1 Answers

1
votes

Issue:

By default you cannot detect that. The message headers don't include any information related to that, and the API's Message resource doesn't have any field which can clarify that.

Also, even though Scheduled is a reserved system label and so labels cannot be created with that name:

enter image description here

Scheduled is not a label which can be found in the API (e.g. by calling users.labels.list), so you cannot filter messages (e.g. using users.messages.list) according to whether they have this label.

Workaround:

  • Create a custom label for schedule messages, and apply this label to these messages:

enter image description here

You can then list the messages that contain this label.

  • To do that, you should first retrieve the corresponding labelId, which you can fetch by first calling users.labels.list.

  • And then call users.messages.list and add the previous id to labelIds, so that only messages with this label are returned:

enter image description here

File a Feature Request:

I'd suggest you to file a Feature Request in the corresponding Issue Tracker's component, so that scheduled messages can be programmatically listed through Gmail API.