This project is read-only.

A couple or problems

Jan 21, 2011 at 3:31 AM

I basically am looking to monitor a gmail account. I can log in and get all the items in the inbox - well, everything except the message bodies:

Getting message bodies:
OK, so first, here is some sample code that works - except that TextData, HtmlData, and the attachments are not there. Is there some method I need to call to populate that data? Also, ContentLoaded is false:

    IMAPClient client = new IMAPClient();
    client.Config = 
        new IMAPConfig("", 
            "", "secretpass", true, true, "");

    foreach (IMAPMessage message in client.Folders["INBOX"].Messages)
            // TextData is null
            model.Add(new MailModel()
                From = message.From[0].DisplayName,
                //Body = message.TextData.TextData,
                Subject = message.Subject,
                ItemDate = message.Date.ToLocalTime(),
                MailId = message.Uid,
                IsNew = message.Flags.New

Any ideas on what I'm doing wrong here? I can see the from, to, subject, etc - but the actual message body is not there.

Seeing if a message is "new" or not:
From the code sample above, the message.Flags.New is ALWAYS false. This seemed like a nice way to differentiate if an e-mail is new or not but it doesn't work. Any idea what's wrong here? Is there any alternative to seeing if the message has been read or not?

Best-practices for monitoring for new messages:
IMAP natively supports the notion of "idle" where the caller will be notified when a new message arrives. I could find this in this implementation, is that supported? Or, should the developer just poll over 15 minutes or so? Also, I noticed that the IMAPClient doesn't implement IDisposable, which i would expect if the resources for that component (like the network stream) are to be cleaned up. Is it alright to use the code sample like above or is there some other calling convention that would be better? This is for a monitoring application that will run 24/7 and I don't want to have a memory leak.

Anyone have any thoughts on these? thanks!