login about faq


frequently we are getting below error ,our mail box contains more than 1 lakh mails ChilkatLog: Expunge: Not connected to an IMAP server. Not in the authenticated state --Expunge --ChilkatLog

   i had written code like below
        //current settings are 
      ConnectTimeout = 60, 
      ReadTimeout = 30, 
      AutoDownloadAttachments = false

        using (Imap imap = GetImapClient(serverName, username, password))
            int numofEmails = imap.NumMessages;
            for (int currentIndex = 1; currentIndex <= numofEmails; currentIndex += 10)
                    using (EmailBundle bundle = imap.FetchSequence(currentIndex, 10))
                        if (bundle == null || bundle.MessageCount <= 0)
                        //  Process the bundle...
                        for (int j = 0; j < bundle.MessageCount; j++)
                            using (Email email = bundle.GetEmail(j))
                                if (ProcessEmail(email))
                                    imap.SetMailFlag(email, "Deleted", 1);


current work around i had done checking imap.connection before expunge if connection is not available reconnect again and call the expunge.

we are calling expunge for each 10 mails ,is this correct or expugne should call after marking all the mails with deleted if that the case if the application corrputs before calling expugne and after marking deleted true . please guide. Note: one more observation reading is faster with marking delete ,is their any other way to do above the work.

Thanks and regards, Harish Chepuri

asked Apr 27 '13 at 06:03

harishchepuri's gravatar image


If a Chilkat IMAP method call that sends a command to the IMAP server returns with a "Not connected to an IMAP server." in the LastErrorText, it means the connection was lost in a previous method call (or the connection was never made in the first place). The return value of each Chilkat IMAP method call must be checked for success/failure. If it failed, you might wish to call the Imap.IsConnected() method (note that it's a method and not a property) to check to see if the connection to the server still exists.

In your code snippet above, the calls to SetMailFlag and Expunge are NOT checked for success/failure.


answered Apr 29 '13 at 08:14

chilkat's gravatar image

chilkat ♦♦


thanks you for your reply to my mail, connection was established in the method GetImapClient,why connection was lost and can i get know which method was created problem. one more question if my mail box has 2 lakhs mails should i call expugne after completion of marking all the 2 laksh mails with marking delete or for each set. some times i am getting email bundle is null .

Thanks and Regards, Harish Chepuri

(Apr 29 '13 at 08:22) harishchepuri
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Apr 27 '13 at 06:03

Seen: 5,049 times

Last updated: Apr 29 '13 at 08:22

powered by OSQA