OMID
OMID

Reputation: 2739

"The IMAP server has unexpectedly disconnected" on Mailkit GetMessage Method

I want to get an email message using mailkit but get this error:"The IMAP server has unexpectedly disconnected" on selectedFolder.GetMessage method.

this problem is for only 2 or 3 messages not all of them.

here is Mailkit log

Connected to imap://*****:143/?starttls=when-available
S: * OK IMAP4rev1 SmarterMail
C: B00000000 CAPABILITY
S: * CAPABILITY IMAP4rev1 AUTH=CRAM-MD5 UIDPLUS QUOTA XLIST CHILDREN
S: B00000000 OK CAPABILITY completed
C: B00000001 AUTHENTICATE CRAM-MD5
S: + PDE4MDMxODE3NDkuNjMhdGEuY29tPg==
C: bW9zbGVtaUBwaWRtY28uaXIgZjUwZxYjhlNDQ=
S: B00000001 OK CRAM authentication successful
C: B00000002 CAPABILITY
S: * CAPABILITY IMAP4rev1 AUTH=CRAM-MD5 UIDPLUS QUOTA XLIST CHILDREN
S: B00000002 OK CAPABILITY completed
C: B00000003 LIST "" ""
S: * LIST (\Noselect) "/" ""
S: B00000003 OK LIST completed
C: B00000004 LIST "" "INBOX"
S: * LIST (\HasNoChildren) "/" "Inbox"
S: B00000004 OK LIST completed
C: B00000005 XLIST "" "*"
S: * XLIST (\HasNoChildren \Trash) "/" "Deleted Items"
S: * XLIST (\HasNoChildren) "/" "ESET Antispam"
S: * XLIST (\HasNoChildren \Inbox) "/" "Inbox"
S: * XLIST (\HasNoChildren) "/" "Infected Items"
S: * XLIST (\HasNoChildren \Spam) "/" "Junk E-Mail"
S: * XLIST (\HasNoChildren \Sent) "/" "Sent Items"
S: * XLIST (\HasNoChildren) "/" "Drafts"
S: B00000005 OK XLIST completed
C: B00000006 EXAMINE Inbox
S: * 44 EXISTS
S: * 0 RECENT
S: * OK [UNSEEN 24] Message 24 is first unseen
S: * OK [UIDVALIDITY 0] UIDs valid
S: * OK [UIDNEXT 1869] Predicted next UID
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS ()]
S: B00000006 OK [READ-ONLY] EXAMINE completed
C: B00000007 UID FETCH 1826 (BODY.PEEK[])
S: * 4 FETCH (BODY[] 

Upvotes: 0

Views: 2144

Answers (1)

jstedfast
jstedfast

Reputation: 38528

The problem is that your TCP/IP connection with the server is being severed.

This can happen for any number of reasons, including:

  1. the server crashed
  2. the server was rebooted
  3. the server lost its network connection
  4. the client lost its network connection

You just need to handle these unexpected disconnects by attempting to reconnect and re-issuing the command.

Upvotes: 1

Related Questions