Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulling messages from GMail terribly slow #5

Closed
Arcturus5404 opened this issue Sep 26, 2012 · 6 comments
Closed

Pulling messages from GMail terribly slow #5

Arcturus5404 opened this issue Sep 26, 2012 · 6 comments

Comments

@Arcturus5404
Copy link

I am trying to set up a project so that I can monitor a GMail account. When I log in, and fetch my messages from my inbox (25 messages with some attachements), it is really really slow..

What am I doing wrong?

client = new ImapClient("imap.gmail.com", 993, Email, Password, AuthMethod.Login, true);

client.NewMessage += OnNewMessage;

//takes 10 seconds to get this point...
uint[] uids = client.Search(SearchCondition.All(), client.DefaultMailbox); //Takes aprox 15 seconds to get the ids..
MailMessage[] messages = client.GetMessages(uids); //Takes minutes...
@smiley22
Copy link
Owner

huh that is weird. Your code is fine.

Try commenting out the OnNewMessage line, does that make any difference? I just ran a couple of tests on Gmail fetching some 50 mails without problems. What size are the attachments?

@Arcturus5404
Copy link
Author

Hmm I will test again this evening..

It might be the case that I switched from AE.Net.Mail, and I received a System.Net.Sockets.SocketException in the method ReadToEnd, so I switched to your dll.

Could it be that there might be still some connections on GMail that might not have timed out yet?

Also, I see that I get the client instance in the event. Is it advisable to Dispose it where its created? or keep it in a local field?

Last question: how do I get the received date from an email? :)

Thanks for your help!! Much appreciated

@Arcturus5404
Copy link
Author

Attachements are aprox 1 MB in size btw :)

@smiley22
Copy link
Owner

OK, well I don't know about lingering connections, I don't think that should have anything to do with it...well unless there was still some instance actively downloading stuff in the background and hogging your internet connection.

You shouldn't dispose of the client instance in the event handler. Disposing will close the network stream and shutdown the tcp connection with the server.

As for the date, if the mail header contains a date, it should be in the Headers collection, i.e. myMail.Header["Date"]

@Arcturus5404
Copy link
Author

Awesome.. Thanks.. will test again this evening! :)

@Arcturus5404
Copy link
Author

It works like a charm now.. I think it was just a fluke at GMails side! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants