Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeleteAllMessages not working on Pop3Client #184

Closed
bradykelly opened this issue May 10, 2015 · 3 comments
Closed

DeleteAllMessages not working on Pop3Client #184

bradykelly opened this issue May 10, 2015 · 3 comments
Labels
bug Something isn't working

Comments

@bradykelly
Copy link

I am trying to clear a mailbox, with the method below (excuse the vb, not my fault):

Public Sub DeleteAllMessages()

    If _pop3Client Is Nothing Then
        _pop3Client = BuildPop3()
    End If

    If Not _pop3Client.IsConnected Then
        ConnectPop3()
    End If

    _pop3Client.DeleteAllMessages()
    _pop3Client.Disconnect(True)

End Sub

Yet GetMessageCount still always returns a 7, i.e nothing seems to be getting deleted. Then, I don't see any DELE command in the log file written:

Connected to pop://mail.amadigital.com:110/?starttls=when-available
S: +OK POP3
C: CAPA
S: +OK CAPA list follows
S: USER
S: UIDL
S: TOP
S: .
C: USER process@amadigital.com
S: +OK Send your password
C: PASS ADproc14
S: +OK Mailbox locked and ready
C: CAPA
S: +OK CAPA list follows
S: USER
S: UIDL
S: TOP
S: .
C: QUIT
S: +OK POP3 server saying goodbye...

My own DeleteAllMessages is the only method called, so I know only this method writing to the log.

jstedfast added a commit that referenced this issue May 10, 2015
…essageCount()

Since the assumption that all consumers of the MailSpool API would
immediately call GetMessageCount() (and that assumption turned out
to be wishful thinking), I have decided to instead make this
behavior explicit by adding a Count property and Obsoleting
the GetMessageCount() method.

Fixes issue #184
@jstedfast
Copy link
Owner

The reason that DeleteAllMessages() is not doing anything is because I had (apparently wrongly) assumed that consumers of the API would call GetMessageCount() before doing anything (in general, doing anything without knowing the message count is impossible).

When GetMessageCount() is called, it caches the message count which is later used for validating index arguments to the various methods that take indexes as well as using it in the DeleteAllMessages() case to determine how many messages there are to delete.

Since it is clear that this assumption was wrong, I have modified Pop3Client to query the message count itself automatically once the client is authenticated. This means that I can now have a Count property instead of forcing consumers of the API to call GetMessageCount() and so I have also now [Obsolete]'d the GetMessageCount() method.

@bradykelly
Copy link
Author

Thanks Jeffrey. Looks like that might have had an impact on my deletes for single messages as well, but that "magically' vanished, I think because I started calling GetMessageCount before calling delete.

@jstedfast
Copy link
Owner

No problem. I've just released MailKit 1.0.16 with this fix to nuget.org as well.

@jstedfast jstedfast added the bug Something isn't working label May 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants