Search code examples
google-apps-scriptgoogle-apigmailgoogle-workspace

Can email be deleted from your users' Gmail inboxes programmatically via API?


The "Find and delete malicious emails" page in the Google Workspace Admin Help Center states:

Using the investigation tool, you can identify all users in your domain that have received the message (for example, a phishing email). You can then use the investigation tool to delete the email from your users' Gmail inboxes (note that log data might take up to a few minutes before being available in the investigation tool).

From this, I understand that, assuming you have the right package, it is possible to use the investigation tool to delete the unwanted email from your users' Gmail inboxes.

Can I delete emails from my users' Gmail inboxes via Google App Script using the API? If so, how can I do that?


Solution

  • Currently it is not possible with the Investigation tool

    But there is already an existing feature request for exposing the Google Workspace Investigation Tool programmatically.

    I recommend you to "star" it to show Google that more people are interested in this feature - hopefully this will accelerate the implementation.

    UPDATE:

    In th meantime you can use a workaround, e.g. using a service account with domain-wide delegation as suggested by @TheAddonDepot