Can Gmail messages be archived via the API?

2019-07-20 19:35发布

问题:

It doesn't appear to be possible to archive mail using the API. Archiving in the web interface involves moving, rather than labeling a message to "All Mail". Not only is there no "All Mail" label listed by the API, but move is missing as well. There is only modify and this allows only adding or removing labels from a message. This is strange, because the docs say it's possible to "Create filters to automatically label, forward, or archive messages". Additionally, the filters action API includes only forward, addLabelIds and removeLabelIds.

Is there something I'm not seeing, yet?

回答1:

if you check the documentation filters it appears that you need to remove the label INBOX

action.removeLabelIds=['INBOX']