MailKit.Net.Imap.ImapFolder.Open throws exception 'Unable to cast object of type 'System.Char' to type 'System.String'.'

Created on 13 Jun 2017  路  1Comment  路  Source: jstedfast/MailKit

We use MailKit to poll various email servers operated by our customers. The code we have works for most of our customers, however for one of our customer we're getting this exception on ImapFolder.Open().

Exception message:

System.InvalidCastException: 'Unable to cast object of type 'System.Char' to type 'System.String'.'

Stack trace:

at MailKit.Net.Imap.ImapEngine.ProcessUntaggedResponse(CancellationToken cancellationToken)
at MailKit.Net.Imap.ImapCommand.Step()
at MailKit.Net.Imap.ImapEngine.Iterate()
at MailKit.Net.Imap.ImapEngine.Wait(ImapCommand ic)
at MailKit.Net.Imap.ImapFolder.Open(FolderAccess access, CancellationToken cancellationToken)

Code:

private IList<UniqueId> GetMessageIds(IMailFolder folder)
{
    folder.Open(FolderAccess.ReadWrite);
    folder.Check();
    return folder.Search(SearchQuery.DoesNotHaveFlags(MessageFlags.Flagged));
}

Protocol log:

Connected to imaps://imap.[[REDACTED]].com:993/
S: * OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID AUTH=PLAIN AUTH=LOGIN SASL-IR] .[[REDACTED]].com Cyrus IMAP4 v2.3.7-Invoca-RPM-2.3.7-16.el5_11 server ready
C: B00000000 AUTHENTICATE PLAIN [[REDACTED]]
S: B00000000 OK [CAPABILITY IMAP4 IMAP4rev1 LITERAL+ ID LOGINDISABLED ACL RIGHTS=kxte QUOTA MAILBOX-REFERRALS NAMESPACE UIDPLUS NO_ATOMIC_RENAME UNSELECT CHILDREN MULTIAPPEND BINARY SORT SORT=MODSEQ THREAD=ORDEREDSUBJECT THREAD=REFERENCES ANNOTATEMORE CATENATE CONDSTORE IDLE LISTEXT LIST-SUBSCRIBED X-NETSCAPE URLAUTH] Success (tls protection)
C: B00000001 NAMESPACE
S: * NAMESPACE (("INBOX/" "/")) (("user/" "/")) (("" "/"))
S: B00000001 OK Completed
C: B00000002 LIST "" "INBOX"
S: * LIST (\HasChildren) "/" "INBOX"
S: B00000002 OK Completed (0.000 secs 5 calls)
C: B00000003 SELECT INBOX (CONDSTORE)
S: * FLAGS (\Answered \Flagged \Draft \Deleted \Seen)
S: * OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen *)]
S: * OK (seen state failure) Unable to preserve \Seen state: System I/O error
S: * 67 EXISTS
S: * 67 RECENT
S: * OK [UNSEEN 1]
S: * OK [UIDVALIDITY 1316426398]
S: * OK [UIDNEXT 68]
S: * OK [NOMODSEQ] Sorry, modsequences have not been enabled on this mailbox
S: B00000003 OK [READ-WRITE] Completed

bug

Most helpful comment

Thanks!

>All comments

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

MaximKiselev picture MaximKiselev  路  7Comments

rhagh picture rhagh  路  5Comments

SpiritBob picture SpiritBob  路  4Comments

wayneguow picture wayneguow  路  5Comments