0

I cannot connect to any mail accounts to retrieve emails using the AE NET Mail IMAP library. I've used it a while ago and it's good, but I've come back to it and in a new project it's not working for any email account. I have the following code:

        using (var client = new AE.Net.Mail.ImapClient(
            "mail.live.com",
            "myemail@outlook.com",
            "password_SV",
            ImapClient.AuthMethods.Login, 993, false
            ))
        {
            client.SelectMailbox("INBOX");
            AE.Net.Mail.MailMessage[] mailmessage = client.GetMessages(0, 5, false, true);

            foreach (AE.Net.Mail.MailMessage msg in mailmessage)
            {
                collection.Add(new Message()
                {
                    Id = msg.MessageID,
                    Sender = msg.Sender,
                    Subject = msg.Subject,
                    Content = msg.Body
                });
            }
            client.Logout();
            client.Disconnect();

            list.ItemsSource = collection;

But for some reason it just keeps loading (the spinning loading cursor) and the whole UI blocks up. After waiting for 10 minutes - absolutely nothing happens. It just keeps loading, and loading and loading. What am I doing wrong? How can we retrieve mail? I have also tried other accounts, like gmail, and my own one, but the same issues. How can we retrieve mail from outlook.com?

Ðаn
  • 10,934
  • 11
  • 59
  • 95
James
  • 167
  • 1
  • 3
  • 11
  • @Dan I just realised that on another website. I have tried every single setting I have ever used in the past to connect to Live/Hotmail/Outlook (and about 5 other email services that DO support IMAP) and nothing works. I've compared this code to the old code used in my older projects and it's the same. But neither of them work anymore. :-/ I'm completely stumped. I've setup Try/Catches and breakpoints ... – James Mar 10 '13 at 01:40
  • ...practically everywhere and I just can't see where it's going wrong. However, I have noticed that if I enter an incorrect password, it shows an error (Unauthorized login etc) - so I think that helps. I think it's a sign that it can actually connect given the correct details, so maybe the issue lies after the connection has been made? – James Mar 10 '13 at 01:40
  • On which line of code is it blocking? – Snixtor Mar 10 '13 at 02:09
  • @Snixtor I'm not sure how to determine which line is being blocked. But I think it may be the first part of the `using`. – James Mar 10 '13 at 06:08
  • I figured out what the problem was. It's the casing. – James Mar 10 '13 at 07:14
  • 1
    You find out which line is blocking by hitting "pause" with a debugger attached, or by setting a break point near the code in question and stepping through it line by line, or use any other number of debug options. You should *definitely* look at learning more about the Visual Studio debugger, it is an invaluable development tool. – Snixtor Mar 10 '13 at 08:08
  • Thank you very much @Snixtor, this will help me a lot. – James Mar 10 '13 at 11:43

1 Answers1

1

I cannot connect to Outlook, but I can now connect to my other mail accounts. Most examples have the folder names in all caps, but this won't work for me.

I changed .GetMessages("INBOX"); to .GetMessages("Inbox"); and it worked.

James
  • 167
  • 1
  • 3
  • 11