Deleting Emails From a Mail Server
  • 10 May 2022
  • 1 Minute to read
  • Dark
    Light

Deleting Emails From a Mail Server

  • Dark
    Light

Article Summary

Overview

A Flow can be configured to delete all emails sent by one sender, the first or last email in an account, a set count of emails, unread emails, or even all emails from an account for either an IMAP or POP mail server. The Delete step uses the Unique Id for an email as input, then sends the command to a mail server for the messages that meet the criteria to be deleted. 


Using Gmail with Email steps
With Google depreciating Less Secure App settings for Google accounts, users will need to create App Passwords in order to utilize Email steps with Gmail.



Example

  1. From a Designer Project, create a new Flow
  2. In the Flow Designer, attach a Get Headers step from the Communication > Email > IMAP category of the Toolbox panel to the Start step.
  3. On the Properties panel for the Get Headers step, enter "993" for the Port field, "imap.gmail.com" for the Server field, "1" for Count, and the Username and Password. Check Unread Messages Only and Secure Connection boxes to match the server credentials for the mail server. 

  4. From the same category in the Toolbox panel, add a Delete step. 
  5. On the Delete step's Properties panel, enter the same server credentials used for the Get Headers step. Map the Headers.All UniqueId.First to the Unique Id field.
    The Unique Id is used to identify the Email for the Delete step to delete. Mapping the Get Headers Output to the Delete Step's Unique Id Input allows the step to delete the retrieved message. 
  6. Connect the Delete path to the End step. Click Save to save changes to the Flow.



Debug

  1. From the Flow Designer, select the Debug link from the top Action bar.
  2. Navigate to the Inbox for the Email account and take note of the first few unread messages. 

  3. Click START DEBUGGING. Because the Flow interacts with external systems, the steps can take time to execute. The lag-time seen while debugging is perfectly normal.

  4. Return to and refresh the Inbox to ensure that the Flow successfully deleted the first Unread Email.

Was this article helpful?