This project is read-only.

ImapX Delete email message

May 15, 2013 at 10:56 AM

I'm using the ImapX for reading the email in a windows form application, but the application should delete the message that I received in the past days; the application should save only the emails I received today. The problem is that I can't find the way to delete a specific message; I tried...
1) client.Folders[2].DeleteMessage(messaggio);
2) client.Folders["All mail"].DeleteMessage(messaggio);

...but didn't work.
Could someone please help me?
May 15, 2013 at 4:10 PM
Hi blackpyro,

You're doing everything fine, and the messages should be removed from the server.
There was a small bug that the messages were not removed from the Messages collection in Folder, but i fixed it (use the latest source code from the repository).

Please be sure the DeleteMessage method returns true, only in this case it was possible to remove the message.

Best regards,

Pavel Azanov
May 15, 2013 at 11:23 PM
Hi pavel_azanov,

First of all thank you for the quick reply.
For the application I need the .Net 3.5 ImapX and if your latest update of the source code is for .Net 4.0 ImapX, I can't use it because I must use the .Net 3.5 ImapX.
Can I use the latest update of the source code in .Net 3.5 ImapX ?
If not, there's a way a can "convert" the last update of the source code to .Net 3.5 ?

Thank you, best regards.
May 16, 2013 at 8:59 AM
Good day!

The latest source code of the library can be compiled for .Net 3.5 without any problems, but the binaries in the download section are for .Net 4.0, as not many users request a lower version.

I compiled the library under .Net 3.5 for you, you can download it here:!5gAEEZab!RMZOrg4D24edw0CCEQSD0X0nlJIq13mr0GPLYGRthoY

Kind regards,

Pavel Azanov
May 16, 2013 at 9:18 AM
Dear pavel_azanov,

I'm not sure but i think I tried to compile using the latest code (.Net 4.0) in .net 3.5 but I couldn't, I had problems; anyway, I want to thank you for your help and your support, I will test the library in my application and I will test the DeleteMessage command as soon as possible.

Best regards.
May 16, 2013 at 1:54 PM
You're welcome!

There are currently some problems if you try compiling the sample application under .net 3.5, but the library itself builds fine.
May 17, 2013 at 10:14 AM
Edited May 17, 2013 at 10:16 AM
Good day pavel_azanov,

I included the library you gave me, but the problem still persist, I cannot delete a specidif email, a group of emails, or an entire folder, I tried the following commands without success:
FolderCollection folders = client.Folders["[Gmail]"].SubFolder;
MessageCollection AllMail = folders[0].Messages;
FolderCollection folders = client.Folders["[Gmail]"].SubFolder;
MessageCollection AllMail = folders[0].Messages;
if (client.Folders["[Gmail]"].MoveMessageToFolder(msg, folders[6]))
if (client.Folders["[Gmail]"].MoveMessageToFolder(msg, folders[6]))
If I'm making a mistake or the syntax is incorrect, please help.
May 17, 2013 at 3:31 PM

First of all, not all folders can be deleted, only the ones that can be selected, not have subfolders and are allowed to be deleted by the server. If you're using methods to delete or move messages, please call this methods on the folder where this message is inside, not on another.

You can take a look at the sample application, the code for deleting messages or even emptying an entire folder is implemented there.

Best regards,

Pavel Azanov