ImapX Delete email message

May 15, 2013 at 9:56 AM
Greetings,

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?
Coordinator
May 15, 2013 at 3: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 10: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.
Coordinator
May 16, 2013 at 7: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: https://mega.co.nz/#!5gAEEZab!RMZOrg4D24edw0CCEQSD0X0nlJIq13mr0GPLYGRthoY

Kind regards,

Pavel Azanov
May 16, 2013 at 8: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.
Coordinator
May 16, 2013 at 12: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 9:14 AM
Edited May 17, 2013 at 9: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:
1)
FolderCollection folders = client.Folders["[Gmail]"].SubFolder;
MessageCollection AllMail = folders[0].Messages;
folders[0].DeleteFolder();
2)
FolderCollection folders = client.Folders["[Gmail]"].SubFolder;
MessageCollection AllMail = folders[0].Messages;
folders[0].DeleteMessage(msg);
3)
client.Folders["[Gmail]"].DeleteMessage(msg);
4)
client.Folders[1].DeleteMessage(msg);
5)
if (client.Folders["[Gmail]"].MoveMessageToFolder(msg, folders[6]))
folders[6].EmptyFolder();
6)
if (client.Folders["[Gmail]"].MoveMessageToFolder(msg, folders[6]))
folders[6].DeleteFolder();
If I'm making a mistake or the syntax is incorrect, please help.
Coordinator
May 17, 2013 at 2:31 PM
Hi,

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