This project is read-only.

"Expression Times Out" Error when looping through messages

Topics: Help requests
Nov 20, 2015 at 4:12 PM
This is the code I'm using in to connect to a gmail account and display emails
The problem is that when I get to my for loop, myinbox.messages gives me an error myinbox.messages: "Evaluation of expression or statement timed out."
and it wont loop through the messages unless I debug it and refresh
     client = New ImapX.ImapClient("", True)
    client.Login("Email", "Password")
    client.Behavior.NoopIssueTimeout = 120
    client.Behavior.AutoPopulateFolderMessages = True
           dim  myinbox = client.Folders.inbox           
        For Each Message In myinbox.messages
             'save them into an array
Nov 21, 2015 at 1:07 PM
Hi DMandy,

I expect you see this exception when trying to see the values in the watch window during debug time. This happens because the messages are being downloaded at same time as you try to access the collection. This takes time, so the evaluation will time out. You can call the Download method on the Messages collection first to download the messages, before you iterate through the collection.


Nov 23, 2015 at 3:13 PM
Edited Nov 23, 2015 at 3:14 PM
How long should it take for the messages to download?
The code just sits there for five minutes doing nothing and then bugs out with a
"ContextSwitchDeadlock was detected" ERROR