0 votes

How do I read mail folder which name contains "/" ?

by

1 Answer

0 votes

I assume that by reading the folder you mean reading emails from this folder. You do this in the same way as you would do with any other folder - use Imap.Select method.

Some additional points:

  • '/' is not necessarily path delimiter. Some IMAP servers use dot char ('.') for that.
  • If '/' is a hierarchy delimiter, creating such folder (e.g. "foo/bar") for the server should be equivalent to creating "foo" folder and a child folder named "bar" (RFC 3501 section 6.3.3).

Here's the code:

using (Imap imap = new Imap())
{
    imap.Connect("imap.example.com");    // or ConnectSSL for SSL
    imap.UseBestLogin("user", "password");

    imap.Select("INBOX/folder1");

    Console.WriteLine(
        "There are {0} messages in 'INBOX/folder1'",
        imap.GetAll().Count);

    imap.Close();
}
by (297k points)
...