This project is read-only.

Running a batch job

Mar 30, 2011 at 7:58 PM

I have a scenario where I will be receiving thousands of emails with attachments at a time. What's the most efficient way to read each message and download attachment. Create a single IMAP client and just run through a linq query or somehow utilize the TPL library? Any insight would be helpful.

Mar 30, 2011 at 8:35 PM

It depends, usually an IMAP server only allows a finite amount of parallel connections, therefor I doubt you won"t be able to get more up and running than 5.

You could check for the total message count inside the mailbox by selecting it. Let's assume u have 3000 mails, then you could split the task to 2 or 3 connections each fetching different sections, 0 - 1000, 1001 - 2000 and 2001 - 3000. I guess this will be as speedy as it gets, but remember different servers have different restrictions. You will probably encounter servers which will inhibit any connection attempt past the first, you"ll need to try and fall back to a single connection solution if necessary.


Mar 30, 2011 at 8:56 PM

I appreciate the suggestion. Thank you for the prompt response. My provider is google apps gmail so we'll see how it goes.