Using of IMAP flags throws Exception

0 votes
asked Aug 6, 2013 by HPS (170 points)
edited Aug 7, 2013

Hello,

I'm evaluating Rebex Secure Mail and have the following problem. I need to set the flags of a mail (IMAP). The host is outlook.office365.com.

If I use:

Using mailClient As New Imap Dim result = mailClient.Connect("outlook.office365.com", 993, SslMode.Implicit) mailClient .login... ... get some messages ... entry.SequenceNumber = 1 mailClient.SetMessageFlags(entry.SequenceNumber, ImapFlagAction.Add, ImapMessageFlags.Flagged)

an exception "Command received in Invalid state (NO)." is thrown.

Another product, which I'm evaluaiting, sets the flag without problems. What's going wrong?

commented Aug 6, 2013 by Lukas Pokorny (126,910 points)
edited Aug 6, 2013

Hello, please create a communication log using Imap object's LogWriter property (as described here) and either post it here or mail it to support@rebex.net - we should then be able to tell what is going on and fix the issue. Thanks!

2 Answers

0 votes
answered Aug 6, 2013 by HPS (170 points)
edited Aug 6, 2013

Hello,

here is my log-file.

Greetings Hans-Peter

2013-08-06 16:29:43.304 Opening log file.
2013-08-06 16:29:43.332 INFO Imap(1)[8] Info: Connecting to outlook.office365.com:993 using Imap 2.0.4700.0 (trial version).
2013-08-06 16:29:43.455 DEBUG Imap(1)[8] Info: Connection succeeded.
2013-08-06 16:29:43.457 DEBUG Imap(1)[8] Info: Upgrading connection to TLS/SSL.
2013-08-06 16:29:43.475 INFO Imap(1)[8] TLS: State StateChange:Negotiating
2013-08-06 16:29:43.475 DEBUG Imap(1)[8] TLS: HandshakeMessage:ClientHello was sent.
2013-08-06 16:29:43.519 DEBUG Imap(1)[8] TLS: HandshakeMessage:ServerHello was received.
2013-08-06 16:29:43.522 DEBUG Imap(1)[8] TLS: HandshakeMessage:Certificate was received.
2013-08-06 16:29:43.522 DEBUG Imap(1)[8] TLS: HandshakeMessage:ServerHelloDone was received.
2013-08-06 16:29:43.525 DEBUG Imap(1)[8] TLS: Verifying server certificate ('CN=outlook.com, OU=Exchange, O=Microsoft Corporation, L=Redmond, S=Washington, C=US').
2013-08-06 16:29:43.613 DEBUG Imap(1)[8] TLS: Certificate verification result: Accept
2013-08-06 16:29:43.624 DEBUG Imap(1)[8] TLS: HandshakeMessage:ClientKeyExchange was sent.
2013-08-06 16:29:43.633 DEBUG Imap(1)[8] TLS: CipherSpec:ChangeCipherSpec was sent.
2013-08-06 16:29:43.635 DEBUG Imap(1)[8] TLS: HandshakeMessage:Finished was sent.
2013-08-06 16:29:43.663 DEBUG Imap(1)[8] TLS: CipherSpec:ChangeCipherSpec was received.
2013-08-06 16:29:43.664 DEBUG Imap(1)[8] TLS: HandshakeMessage:Finished was received.
2013-08-06 16:29:43.665 INFO Imap(1)[8] TLS: State StateChange:Secured
2013-08-06 16:29:43.665 INFO Imap(1)[8] TLS: Connection secured using cipher: TLS 1.0, RSA, 128bit RC4, SHA1
2013-08-06 16:29:43.667 DEBUG Imap(1)[8] TLS: Session ID: 
 0000 |4E-1E-00-00-67-07-3F-43 52-AA-30-94-EA-D6-A7-05| N...g.?CR.0.....
 0010 |AD-15-BF-1F-5C-4C-BA-77 5D-B9-5A-CA-05-A7-DB-EB| ....\L.w].Z.....
2013-08-06 16:29:43.667 DEBUG Imap(1)[8] Info: Connection upgraded to TLS/SSL.
2013-08-06 16:29:43.744 INFO Imap(1)[8] Response: * OK The Microsoft Exchange IMAP4 service is ready. [QQBNAFgAUABSADAAMwBDAEEAMAAwADkALgBlAHUAcgBwAHIAZAAwADMALgBwAHIAbwBkAC4AbwB1AHQAbABvAG8AawAuAGMAbwBtAA==]
2013-08-06 16:29:43.755 INFO Imap(1)[8] Command: R00001 CAPABILITY
2013-08-06 16:29:43.770 INFO Imap(1)[8] Response: * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN UIDPLUS CHILDREN IDLE NAMESPACE LITERAL+
2013-08-06 16:29:43.770 INFO Imap(1)[8] Response: R00001 OK CAPABILITY completed.
2013-08-06 16:29:43.779 INFO Imap(1)[8] Command: R00002 AUTHENTICATE PLAIN
2013-08-06 16:29:43.793 INFO Imap(1)[8] Response: +
2013-08-06 16:29:43.793 INFO Imap(1)[8] Command: ****************************************************
2013-08-06 16:29:47.592 INFO Imap(1)[8] Response: R00002 OK AUTHENTICATE completed.
2013-08-06 16:29:47.595 INFO Imap(1)[8] Command: R00003 STATUS INBOX (UNSEEN)
2013-08-06 16:29:47.629 INFO Imap(1)[8] Response: * STATUS INBOX (UNSEEN 0) 
2013-08-06 16:29:47.629 INFO Imap(1)[8] Response: R00003 OK STATUS completed.
2013-08-06 16:29:47.630 INFO Imap(1)[8] Command: R00004 EXAMINE INBOX
2013-08-06 16:29:47.659 INFO Imap(1)[8] Response: * 78 EXISTS
2013-08-06 16:29:47.659 INFO Imap(1)[8] Response: * 0 RECENT
2013-08-06 16:29:47.659 INFO Imap(1)[8] Response: * FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
2013-08-06 16:29:47.659 INFO Imap(1)[8] Response: * OK [PERMANENTFLAGS ()] Permanent flags
2013-08-06 16:29:47.659 INFO Imap(1)[8] Response: * OK [UIDVALIDITY 14] UIDVALIDITY value
2013-08-06 16:29:47.659 INFO Imap(1)[8] Response: * OK [UIDNEXT 235] The next unique identifier value
2013-08-06 16:29:47.659 INFO Imap(1)[8] Response: R00004 OK [READ-ONLY] EXAMINE completed.
2013-08-06 16:29:48.991 INFO Imap(1)[8] Command: R00005 FETCH 1:* (UID RFC822.SIZE FLAGS INTERNALDATE)
2013-08-06 16:29:49.019 INFO Imap(1)[8] Response: * 1 FETCH (UID 108 RFC822.SIZE 45081 FLAGS (\Seen \Flagged) INTERNALDATE "10-Jul-2013 12:10:12 +0200")
2013-08-06 16:29:49.021 INFO Imap(1)[8] Response: * 2 FETCH (UID 110 RFC822.SIZE 20444 FLAGS (\Seen \Flagged) INTERNALDATE "11-Jul-2013 19:23:23 +0200")
2013-08-06 16:29:49.021 INFO Imap(1)[8] Response: * 3 FETCH (UID 111 RFC822.SIZE 23504 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 19:23:39 +0200")
2013-08-06 16:29:49.021 INFO Imap(1)[8] Response: * 4 FETCH (UID 112 RFC822.SIZE 20813 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 19:24:40 +0200")
2013-08-06 16:29:49.021 INFO Imap(1)[8] Response: * 5 FETCH (UID 113 RFC822.SIZE 32137 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 19:25:07 +0200")
2013-08-06 16:29:49.021 INFO Imap(1)[8] Response: * 6 FETCH (UID 114 RFC822.SIZE 21930 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 19:47:38 +0200")
2013-08-06 16:29:49.021 INFO Imap(1)[8] Response: * 7 FETCH (UID 115 RFC822.SIZE 25926 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 19:47:48 +0200")
2013-08-06 16:29:49.021 INFO Imap(1)[8] Response: * 8 FETCH (UID 116 RFC822.SIZE 17821 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 19:59:34 +0200")
2013-08-06 16:29:49.021 INFO Imap(1)[8] Response: * 9 FETCH (UID 117 RFC822.SIZE 43297 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 19:59:49 +0200")
2013-08-06 16:29:49.021 INFO Imap(1)[8] Response: * 10 FETCH (UID 118 RFC822.SIZE 17863 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 20:02:16 +0200")
2013-08-06 16:29:49.021 INFO Imap(1)[8] Response: * 11 FETCH (UID 119 RFC822.SIZE 21977 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 20:02:54 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 12 FETCH (UID 121 RFC822.SIZE 21736 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 20:24:41 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 13 FETCH (UID 122 RFC822.SIZE 23571 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 20:28:44 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 14 FETCH (UID 123 RFC822.SIZE 6867238 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 20:51:06 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 15 FETCH (UID 124 RFC822.SIZE 34451 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 20:51:17 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 16 FETCH (UID 125 RFC822.SIZE 20196 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 21:04:22 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 17 FETCH (UID 126 RFC822.SIZE 21134 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 21:05:28 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 18 FETCH (UID 127 RFC822.SIZE 33338 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 21:08:07 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 19 FETCH (UID 128 RFC822.SIZE 19405 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 21:08:38 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 20 FETCH (UID 129 RFC822.SIZE 647849 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 21:08:46 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 21 FETCH (UID 130 RFC822.SIZE 226719 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 21:10:11 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 22 FETCH (UID 133 RFC822.SIZE 33813 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 21:20:28 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 23 FETCH (UID 134 RFC822.SIZE 34604 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 21:27:28 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 24 FETCH (UID 135 RFC822.SIZE 19862 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 22:23:30 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 25 FETCH (UID 136 RFC822.SIZE 20696 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 22:24:12 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 26 FETCH (UID 137 RFC822.SIZE 23847 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 23:11:11 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 27 FETCH (UID 138 RFC822.SIZE 1164350 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 23:13:03 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 28 FETCH (UID 139 RFC822.SIZE 77340 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 23:14:12 +0200")
2013-08-06 16:29:49.022 INFO Imap(1)[8] Response: * 29 FETCH (UID 140 RFC822.SIZE 8051253 FLAGS (\Seen) INTERNALDATE "11-Jul-2013 23:17:1
+1 vote
answered Aug 6, 2013 by Lukas Pokorny (126,910 points)
edited Aug 7, 2013

Thanks for the log!

The following part of the log (at 2013-08-06 16:29:47.630) indicates you opened the "Inbox" folder in read-only mode:

  Command: R00004 EXAMINE INBOX
  Response: * 78 EXISTS
  Response: * 0 RECENT
  Response: * FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
  Response: * OK [PERMANENTFLAGS ()] Permanent flags
  Response: * OK [UIDVALIDITY 14] UIDVALIDITY value
  Response: * OK [UIDNEXT 235] The next unique identifier value
  Response: R00004 OK [READ-ONLY] EXAMINE completed.

To fix this, instead of calling Imap object's SelectFolder("Inbox", true), please try calling SelectFolder("Inbox", false) or simpy SelectFolder("Inbox") and let me know whether it helps.

It's a pitty outlook.office365.com (and MS Exchange as well) don't provide a more useful error message in this case.

commented Aug 7, 2013 by HPS (170 points)
edited Aug 7, 2013

Hello Lukas,

my fault - it works after the change. :)

Thank you for your help.

...