Skip to main content

Delete all emails

Delete every email in a folder that matches the optional filters, to Deleted Items or permanently.

Command in the Microsoft 365 toolkit · id ooa.microsoft365/delete_all_mail · 12 inputs, 1 output

Inputs​

InputTypeRequiredDefaultWhat it is
Access tokenCredentialNoMicrosoft Graph access token from the vault; or leave it empty and choose a connection that signs in, which gets and renews the token.
FolderStringNoinboxFolder id or well-known name: inbox, archive, sentitems, deleteditems.
Unread onlyBooleanNofalseOnly unread emails.
From containsStringNoSender contains this text; separate several with ; to match any of them.
Subject containsStringNoSubject contains this text; separate several with ; to match any of them.
PermanentBooleanNofalseRemove permanently instead of moving to Deleted Items.
Maximum resultsNumberNo1000Most emails to delete in one run.
Read onlyBooleanNofalseOnly emails already read.
SinceDateTimeNoReceived on or after this time (UTC).
BeforeDateTimeNoReceived before this time (UTC).
MailboxStringNomeMailbox: me, or a user's email address (needs application permission).
Endpoint addressStringNohttps://graph.microsoft.com/v1.0Graph endpoint; change only for national clouds or testing.

Outputs​

OutputTypeWhat it is
countNumberNumber of emails deleted.