Delete Emails from IMAP Server

Delete Single Message from Server

To delete a message from an IMAP server, the Aspose.Email library provides the delete_message method of the ImapClient class. It takes the message sequence number or unique ID as a parameter. The following code snippet shows you how to delete an email message with the message ID 1 from an IMAP server:

Delete Multiple Messages from Server

Multiple emails can be deleted from a mailbox using the delete_messages method of the ImapClient class provided by the Aspose.Email API. This method provides a number of options to delete multiple messages from the server using unique ids, sequence numbers or ImapMessageInfoCollection elements. The following code snippet shows you how to delete multiple messages: