andyedinborough / aenetmail

C# POP/IMAP Mail Client
370 stars 153 forks source link

Raising events during getmessages #53

Open piher opened 12 years ago

piher commented 12 years ago

Hi,

Not really an issue, just a very quick question : why not raising an event in getmessages every time a message has been fetched ?

andyedinborough commented 12 years ago

Hmmm. Seems like something that could be done fairly easily in any code that uses the API by creating a simple wrapper. In trying to keep this thing as simple as possible, I'd need a really good reason for it to part of the base code.

piher commented 12 years ago

I may be saying something very naive because I've never learned about wrappers but as an example when calling GetMessages(0,2000,....) i thought it would be of great comfort to trigger an event right after x.add(mail). (so we actually know what's going on inside) Is that possible with a wrapper ?

andyedinborough commented 12 years ago

I think some tracing is in order... I'll be thinking about the best way to implement this.

piher commented 12 years ago

I'm sure that would be great. Just FYI, what I did for my personal use was to create a gotMsg event that is raised after x.add(mail), referencing the msg for saving or diplaying purposes, and added a boolean CancellationPending checked at every loop in getmessages to allow a (very) quick cancellation. So far it's been working great for what I need.

andyedinborough commented 12 years ago

I've been meaning to get back to this. I think the best solution is Trace -- http://support.microsoft.com/kb/815788. Various points can be set to call the trace method and when you need to, you can create a TraceListener to see what's happening. Thoughts? What all points would you like to see a trace event fired? Connect, Login, each iteration of GetMessages...

piher commented 12 years ago

Well, that would be great for testing purposes. But actually I was not really thinking about testing, more of a new functionnality. Indeed, I developped a small thunderbird-like email client and when I want to download the whole mailbox the memory usage would grow a lot whereas I don't even need the thousands of mails to be stored in a list since I save them one-by-one. Raising an event at each message allowed me to write a sub that does the same thing as getmessages but "returns" every message one by one.