GemBox Support Forum

PopClient.GetMessage(int MessageNumber) System.ArgumentException: "Offset and length were out of bounds..."

I keep getting the following exception error with PopClient.GetMessage(int messageNumber) even though the messageNumber that I’m passing in clearly exists and is returned with ListMessages. I don’t have this problem with the ImapClient. What seems to be the problem here?

System.ArgumentException: “Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.”


Can you send us a sample code that shows what you’re doing?

Are you passing the PopMessageInfo.Number value to PopClient.GetMessage(int messageNumber) or something else?


I’m trying to do things such as:




Occasionally, things would work.


Is it possible for you to create a Visual Studio project that reproduces your issue and send it to us by submitting a support ticket?

We will need to investigate exactly what does occasions are when the execution fails.
Is it possible that your inbox ends up being empty at some point?
Or that the message is moved/deleted?
Or something else?

In any case, we’ll need to debug this scenario in order to investigate what exactly is happening and why.


Thanks for your response, Mario. It seems that the issue had to do with some of my messages. When I test GetMessage(int messageNumber) on new messages, it always works. I’ll let you know if I run into further issues.