tags:

views:

153

answers:

1

I have asked this question in a different post here on SO:

How can a read receipt be suppressed?

I have been doing some research of my own to try and solve this problem and accessing the e-mail account via IMAP seems like it is going to be a good solution. I have successfully been able to access my own Inbox and mark messages as read with no issue. I have been asked to preform the same task on an Inbox that contains over 23,000 emails. I would like to run the test on a small amount of e-mails from that inbox before letting the whole 23,000 get it.

Here is the code I have been running via telnet:

. LOGIN [email protected] password
. SELECT Inbox
. STORE 1:* flags \Seen  'this line marks all the e-mails as read

So my question is how can i execute that store command on a specific group of e-mails... say emails that are going to / coming from a specific account? Is there a way to like concatenate the commands? like a FETCH then the STORE? Or is there a better way to go about getting a collection of e-mails based on certain criteria and then modifying ONLY those e-mails that can be accomplished through IMAP?

A: 

Take a look at the IMAP SEARCH command. The syntax is really awful, but it'll let you search for recipients or senders, for certain words in the subject or the body of messages. It will give you a list of message ids and you can use those message ids in your call to STORE.

innaM
can I feed the results of the SEARCH command to the STORE command? I was hoping to run STORE command on a few hundred e-mail that were either from a certain user or that fell in a certain date range... would writing some sort of little program to receive the results of the SEARCH command and iterate over the results calling the STORE command on each id returned be something I should consider doing?
swolff1978
Of course! I wouldn't do that over telnet and you cannot say something to the effect of "STORE SEARCH foo bar". You need a way to temporarily store the result of SEARCH to be able to feed it to STORE.
innaM
Manni - One more silly question. How should I make the connection if not through telnet? (using asp.net) System.Net.Sockets.TCPClient?
swolff1978
Sorry, I guess what I said must have been a bit confusing. What I meant was to not do this by manually connecting to your server, but to do this programmatically. On the other hand, I am sure that there is already some kind of IMAP client library for .net somewhere out there.
innaM