+1 vote

Hello, we just bought the Mail.dll library, so far so good, easy and powerful.

Now I'm trying to delete some email.
According to the samples, if we use Gmail we have first to move emails to the trash folder, exact name: "[Gmail]/Trash".

The MoveByUID method returns an exception whose message is:

Error: [TRYCREATE] no folder [Gmail]/Trash (Failure)

The folder exists, there is already some email there.

Is there anything with the name?

Thanks for support.
Emilio

by

1 Answer

0 votes

Your account doesn't necessary have the "[Gmail]/Trash" folder.

For example it may contain national version of that name. Also some Gmail accounts use "[Gmail]/Bin" in English version.

You should use CommonFolders class to recognize folders:

using (Imap imap = new Imap())
{
    imap.ConnectSSL("imap.gmail.com");
    imap.UseBestLogin("pat@gmail.com", "password");

    List<FolderInfo> folders = imap.GetFolders();
    CommonFolders common = new CommonFolders(folders);

    Console.WriteLine("Trash folder: " + common.Trash.Name);

    // You can select folders easily:
    imap.Select(folders.Trash);

    imap.Close();
}

I have updated delete email permanently in Gmail to include this information.

by (301k points)
Thanks for your quick reply

I also found out while waiting for your (very good) answer that I can use the folders to get the right name. The suspect came to me because my Gmail account is in German :-) I've also made a test and it worked properly. Thanks a lot, Emilio
...