0

I'm using the MailSystem.NET OS library for handling IMAP. I have a problem with my client program (written in c#). It polls the mail server using the IMAP library. It marks a message as deleted after adding it into the client db. However, I don't necessarily want to remove the email physically as other clients won't be able to read the email.

So I call DeleteMessage(1, false), which should MARK the email as deleted but since 'expunge' is set false it is not physically removed from the server.

If I open Thunderbird (a different client) and connect to the mailbox, sure enough the message has gone. However, my other client sees the message as still there. The message count shows 1. How do I make sure that when I return the message count from the 'INBOX' mail folder it only returns those that are not marked for deletion, i.e. those that have not already been read by the client program?

3
  • This is mail client dependant and you can't do nothing about it. Select command EXISTS response always returns number of messages in mailbox(not examing any of the message flags).
    – Ivar
    Nov 16, 2011 at 8:34
  • How do I for example get the message count for emails in the Inbox that don't have the 'deleted' flag set?
    – jaffa
    Nov 16, 2011 at 10:47
  • Probably the fastest way is to use IMAP search. You can search for "UNDELETED" messages. UNDELETED search key - Messages that do not have the \Deleted flag set. Defined in RFC 3501 6.4.4.
    – Ivar
    Nov 16, 2011 at 14:19

1 Answer 1

0

As Ivar mentioned in his comment, you can use UNDELETED to search the mailbox for messages. However, I found the "NOT DELETED" search flag to work better on the IMAP library I have been using.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.