Exception: The operation 'CAPABILITY' terminated on loading email using IMAPClient (C# .NET)

Hello,

We are seeing below error frequently (at least few times in a day) when we reading the mails.

The operation ‘CAPABILITY’ terminated. Timeout ‘100000’ has been reached.-The operation ‘CAPABILITY’ terminated. Timeout ‘100000’ has been reached.

Stack Trace:
at Aspose.Email.Clients.Imap.ImapClient.BeginSelectFolder(IConnection connection, String folderName, Boolean readOnly, AsyncCallback callback, Object state) at Aspose.Email.Clients.Imap.ImapClient.SelectFolder(IConnection iConnection, String folderName, Boolean readOnly) at Aspose.Email.Clients.Imap.ImapClient.SelectFolder(String folderName)

Can you please suggest what needs to be done to fix it?

@srinudhulipalla,

Can you please share source files along with sample code so that we may further investigate to help you out.

This is the code I use and it works all the times, suddenly the above mentioned error comes up. Is there limit in processing the number of emails?

        License license = new License();
        license.SetLicense("Aspose.Total.lic");
		
		ImapClient oClient = new ImapClient();
        oClient.Host = oRow["SMTPSERVER"].ToString().Trim();
        oClient.Username = oRow["USERNAME"].ToString().Trim();
        oClient.Password = oRow["USERPASS"].ToString().Trim();
        oClient.Port = Convert.ToInt32(oRow["SMTPPORT"].ToString().Trim());
        bool bSSLEnabled = Convert.ToBoolean(oRow["ENABLED"].ToString().Trim());
        if (bSSLEnabled)
        {
           oClient.SecurityOptions = SecurityOptions.Auto;
        }

        oClient.SelectFolder(ImapFolderInfo.InBox);

        ImapQueryBuilder builder = new ImapQueryBuilder();

        builder.HasNoFlags(ImapMessageFlags.IsRead);

        MailQuery oQuery = builder.GetQuery();

        ImapMessageInfoCollection messageInfoCol = oClient.ListMessages(oQuery);
		
		for (int i = 0; i < messageInfoCol.Count; i++)
		{
			MailMessage oMsg = oClient.FetchMessage(messageInfoCol[i].UniqueId);
			
			//save oMsg object details to DB
		}

@srinudhulipalla,

I have observed the issue shared. We are internally working over it and will get back to you with feedback as soon as possible.

@srinudhulipalla,

I suggest you to please try setting Timeout property to some large value or -1 on your end. I also suggest you to please share a test account reproducing issue on your end as well, so that we may further verify issue on our end.

Is the Timeout link mentioned in above post valid? I couldn’t able to access it.

@srinudhulipalla,

Yes, this link is valid and i am able to access this. can you pleas share what kind of problem you are facing when you tried to access this.

I can able to access it today, I was getting 404 page error yesterday. Thank you.

“Timeout value can not be less then value of NetworkTimeout property”

What is the meaning of above statement wrt. NetworkTimeout?

@srinudhulipalla,

It’s good to know things are fine on your end.

I have shared the solution with you already for setting the TimeOut value in my previous post as well.

I understand.

I have given the Timeout is -1.

But the below link says the property description as “Gets or sets the timeout for mail operations Please note: Timeout value can not be less then value of NetworkTimeout property”

I was trying to understand the part “Timeout value can not be less then value of NetworkTimeout property”. Can you please explain?

@srinudhulipalla,

Please disregard this information as its obsolete. We will be removing this in next version too.

Ok Thank you.

I will set the mail client Timeout as -1

I hope this will not cause any other problems and solves the current ‘CAPABILITY’ terminated issue.

@srinudhulipalla,

Yes, I hope it will resolve the issue.