ClientImap.Connect() Exception

Hi there again,
I am having trouble connecting to an gmail account throug the Imap client.
When I try to connect it fails with this exception " An imap command couldn’t be processed within 100000 ms" but when I pull emails with the outlook there’s no problem.
I based my code on your examples so it’s like this

ImapClient client = new ImapClient(imapAddress, userName,userPassword);
if (activeEvent.EmailSSL != null && (bool)activeEvent.EmailSSL)
{
client.Port = 993;
client.SecurityMode = ImapSslSecurityMode.Explicit;
client.EnableSsl = true;
}
try
{
client.Connect(); // Error


if you need any more info just let me know.
Thanks,
Miguel de Sousa

Hi Miguel de Sousa,

We are sorry for the inconvenience caused to you.

Please use ImapSslSecurityMode.Implicit instead of ImapSslSecurityMode.Explicit in the given sample code. Please refer here for details on connecting to an SSL enabled mail server using the IMAP protocol.

Your updated sample code is given as below:

ImapClient client = new ImapClient(imapAddress, userName,userPassword);
if (activeEvent.EmailSSL != null && (bool)activeEvent.EmailSSL)
{
client.Port = 993;
client.SecurityMode = ImapSslSecurityMode.Implicit;
client.EnableSsl = true;
}
try
{
client.Connect();
}

hi,
thanks it solved the problem I was reading [here ](http://www.aspose.com/docs/display/emailnet/Connecting+with+SSL+Enabled+IMAP+Server), maybe you could put a side note there :).
Thank you for the quick response.
Miguel de Sousa

Hi Miguel de Sousa,

Thanks for pointing out the typo error in the documentation. We have corrected the issue and you may visit [here ](http://www.aspose.com/docs/display/emailnet/Connecting+with+SSL+Enabled+IMAP+Server) again to get modified information.

Hi Kashif,

Thank you for the quick reply. Unfortunately we have a customer using 5.2.0 that is experiencing intermittent failures with the below error and the issue can be fixed by restarting our application. The app will run for days before the error returns.

Failed to get the mailbox info for account 'AP Invoices'. Reason: 'ConnectFailure'

Failed to get the mailbox info for account 'AP Invoices'. Reason: '004 NO LOGIN failed.'

Failed to get the mailbox info for account 'AP Invoices'. Reason: 'An imap command couldn't be processed within 40000 ms'

Can you provide any insight as to what would cause the above error to appear intermittently?

We have another customer running 5.3.0 also that is timing out on the fetch.

Thank you,

Cameron

internal IMAPMailProcessor(SubscriptionAccount account) : base(account)
{
    _client = createImapClient();
    ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidationHandler;
}

private ImapClient createImapClient()
{
    ImapClient client = new ImapClient();
    client.Host = SubscriptionAccount.ConnectionInfo.ServerAddress;
    client.Username = SubscriptionAccount.ConnectionInfo.UserName;
    client.Password = SubscriptionAccount.ConnectionInfo.Password;
    client.Port = (int)SubscriptionAccount.ConnectionInfo.Port;

    if (SubscriptionAccount.ConnectionInfo.UseSSL)
    {
        client.SecurityOptions = Aspose.Email.SecurityOptions.SSLImplicit;
    }
    else
    {
        client.SecurityOptions = Aspose.Email.SecurityOptions.None;
    }

    return client;
}

// The below is called on a timer that in this case runs on an 1 minute interval
protected override MailInfoCollection download()
{
    MailInfoCollection emailList = new MailInfoCollection();
    try
    {
        //this query is for returning only the unread
        ImapQueryBuilder imapbuilder = new ImapQueryBuilder();
        imapbuilder.HasNoFlags(ImapMessageFlags.IsRead);
        Aspose.Email.MailQuery query = imapbuilder.GetQuery();
        ImapMessageInfoCollection messageInfos = _client.ListMessages(query);

        if (messageInfos.Count > 0)
        {
            //Omitted because it is not hit
        }
    }
    catch (Exception e)
    {
        ProcessorErrorMonitor.AccountFailed(MailProcessorErrorMonitorType.DownloadMailboxInfo, e.Message);
        OnMailEvent(MailEventArgs.CreateLog(SubscriptionAccount, SSLogEvent.MailProcessorMailboxInfoFailed, Strings.GetString("STR_SS_MAILPROC_MAILBOXINFO_FAIL", SubscriptionAccount.Name, e.Message), LogSeverity.Error));
    }
}

Hi Cameron,


Aspose.Email for .NET 5.2.0 and 5.3.0 are quite older versions now. The API has gone through a lot of improvements during this time where modifications to IMAP client were also incorporated, resulting in fixing of a number of issues.

We can’t investigate the issues with an older version of the API as the latest new version may not even exhibit the problem. We request you to please download and try the latest version of the API at your end. If the issue still persists, you can try IMAP activity logging for sharing the error details with us (of course with the new version). You can also share a test account credentials with us that we can use at our end for reproducing the issue for further investigations.