0 votes

We have been using your Mail.dll for Read, Send and Delete mails.

For delete, we specifically rely on IMAP's DeleteMessageByUID(...) method, but this deletes the mail permanently from email provider server instead of sending it to Trash/Bin folder.

Is there a way to not to delete mail permanently and send it to a Trash/Bin folder on deletion request? The question is for both : POP3 and IMAP protocols.

by

1 Answer

0 votes

When using IMAP you can use CommonFolders class to identify known folders, you just need to obtain email folders from the server first. CommonFolders.Trash represents a trash/bin folder:

CommonFolders folders = new CommonFolders(imap.GetFolders());
FolderInfo trash = folders.Trash;

Then use Imap.MoveMessageByUID to move the message to the trash folder:

long uid = ...;
imap.MoveMessageByUID(uid, trash);

Unfortunately there is no concept of folders in POP3 (note this is not a limitation of Mail.dll, but the POP3 protocol itself.
Good POP3 server would move messages that were deleted using POP3 to trash folder by itself.

by (301k points)
...