/// <summary> /// Delete a message basend on message identifier. /// </summary> /// <param name="messageId">The message identifier.</param> /// <param name="mailbox">The mailbox for retrieve messages.</param> public void DeleteMessage(string messageId, string mailbox) { Mailbox inbox = this._imap4Client.SelectMailbox(mailbox); Fetch fetch = inbox.Fetch; Header header; int index = 0; int messageCount = inbox.MessageCount; for (int i = 1; i <= messageCount; i++) { header = fetch.HeaderObject(i); if (header.MessageId.Equals(messageId)) { index = i; break; } } if (index > 0) { inbox.DeleteMessage(index, false); } }
public void DeleteEmailByID(int id, string boxName) { Mailbox inbox = _imap4Client.SelectMailbox(boxName); inbox.DeleteMessage(id, true); }