+1 vote

Im using web.de as email, but there are no flags in web.de.

My question, can I get unread emails also without them being flaged?

All my unread emails are in a folder, is it possible to get all the emails from that folder?

Or is there a other way to only get specific emails?

by
All IMAP servers should support flags such as Flag.Seen, are you absolutely sure that your server doesn't support them? What happens when you use imap.Search(Flag.Unseen); ?
If I use any flag it doesn't return a single mail. If I use unflagged it returns all emails.
Flag.Flagged and Flag.Unseen are unrelated. If you want to get unseen emails use Flag.Unseen.
Ok I figured it out thanks

1 Answer

0 votes
 
Best answer

To change the currently selected IMAP folder simply use Imap.Select method:

imap.Select("Folder1");

To list all IMAP folders use Imap.GetFolders method:

foreach (FolderInfo folder in imap.GetFolders())
{
    string name = folder.Name;
}

You can use CommonFolders class to recognize folders and their purpose:

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

    CommonFolders folders = new CommonFolders(imap.GetFolders());

    Console.WriteLine("Inbox folder: " + folders.Inbox.Name);
    Console.WriteLine("Sent folder: " + folders.Sent.Name);
    Console.WriteLine("Spam folder: " + folders.Spam.Name);

    // You can select folders easy:
    imap.Select(folders.Inbox);
    imap.Select(folders.Sent);
    imap.Select(folders.Spam);

    imap.Close();
}
by (301k points)
selected by
...