This project is read-only.

You can execute this command only when State is Authenticated

Oct 2, 2013 at 4:17 PM
I'm reading an IMAP folder.
My code is quite this:

Dim inbox As Imap.ImapFolder = _imapClient.SelectFolder("INBOX")
        For jj = 1 To inbox.MailCount
            Dim message = _imapClient.GetMessage(jj)
' do some stuff using the message

The mailbox has currently 3 messsages. After the DeleteMail, the next loop throw the exception "You can execute this command only when State is Authenticated"

Oct 3, 2013 at 5:45 PM
See this article.
You must reauthenticate required.

(This article is old. I changed method name from DeleteEMail to DeleteMail early this year or more before)
Oct 4, 2013 at 11:08 AM
Thank you
but why do you execute an "ExecuteLogout" in DeleteMail method?

As user of the library it seems more normal:
  • create a cliente
  • logon
  • read
  • delete
  • read
  • delete
  • move, copy, insert, etc.
  • logout
Why delete has a forced logout inside? Is this required by IMAP to complete deletion?
Oct 4, 2013 at 12:48 PM
You are completely right.
DeleteMail method should be

public Boolean DeleteMail(params Int64[] mailIndex)
if (this.EnsureOpen() == ImapConnectionState.Disconnected) { return false; }
if (this.Authenticate() == false) { return false; }

for (int i = 0; i < mailIndex.Length; i++)
    var rs = this.ExecuteStore(mailIndex[i], StoreItem.FlagsAdd, @"\Deleted");
    if (rs.Status != ImapCommandResultStatus.Ok) { return false; }
return true;

I'll modify it in next version.
Thank you for your catching up!