0 votes

Every Time While Fetching Emails from Inbox or sent Items or Drafts.
I am Giving the Imap.Connect(Connection is Establishing Every Time)

I want My connection to be fixed (1 time Authentication)

Connection to be fixed

by

1 Answer

0 votes

Changing working IMAP folder doesn't require you to reconnect. Simply issue new Select command:

using (Imap imap = new Imap())
{
    imap.ConnectSSL("imap.example.com");
    imap.UseBestLogin("user", "password");

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

    imap.SelectInbox();
    List<long> uids = imap.Search(Flag.All);
    // do something with uids here

    imap.Select(common.Drafts);
    uids = imap.Search(Flag.All);
    // do something with uids here

    imap.Select(common.Sent);
    uids = imap.Search(Flag.All);
    // do something with uids here

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