login about faq

Essentially, I just want to make sure I'm doing the most optimal way of retrieving emails of a certain type from the mailbox. The sets can be quite large, 10000s of emails might match a specific subject, and there could be 100000s of mails in the mailbox at a given time.

Say I were to try to to fetch all emails with Subject having "undeliverable" in them.

var mailer = new Imap(); //- mail box setup //- end mail box setup mailer.SelectMailbox("Inbox"); MessageSet set = mailer.Search("SUBJECT Undeliverable", true);

bundle = mailer.FetchBundle(set); EmailBundle bundle;

This process can take a very long time - minutes doing this approach. I'm just trying figure out if there is a more optimal approach to this.

asked Dec 14 '12 at 13:00

keck's gravatar image


I don't think there is a more optimal way on your side (the client side).

If the Search method returns a large set of email UID's, then it might be best to write a loop that fetches them individually, to avoid memory issues or to allow for partial completion w/ the capability of resuming afterwards (such as in a case where a network failure occurs).

I've noticed that some mail servers have very poor SEARCH performance when the number of messages is very large. If the bulk of the time is spent in the SEARCH, you might look at a different overall architecture -- for example, check to see if it's possible to write a filtering rule on the server so that incoming "undeliverables" are immediately moved to a separate mailbox. You could then avoid the SEARCH altogether and just process the "undeliverables" mailbox contents.


answered Dec 17 '12 at 08:46

chilkat's gravatar image

chilkat ♦♦

We were already looking at moving all the failures to another mailbox and profiled that solution. I think that is a great suggestion, and what we'll probably end up going with as even with a 10000 failure messages simulated, it was still pretty quick when no searching was involved.

We have other rules we might need to employ for things that aren't failures, but segmenting them upfront might be what we'll have to do in these instances as well.


(Dec 17 '12 at 08:57) keck
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Dec 14 '12 at 13:00

Seen: 1,525 times

Last updated: Dec 17 '12 at 08:59

powered by OSQA