We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pop3Client ListMessages()

I was having issues accessing a pop3 client after sending a mail with SMTP so I upgraded to Aspose.Net 4.9, now I cannot list messages from my pop3 server. To isolate the issue I created a new sample client with only the problem areas.

My code for getting a list of messages:

private void btnCheckandReply_Click(object sender, EventArgs e)
{
Aspose.Network.License AspLicense = new Aspose.Network.License();
AspLicense.SetLicense("Aspose.Total.lic");
Pop3Client mail = new Pop3Client(txtPopHost.Text, Convert.ToInt32(txtPopPort.Text), txtUserName.Text, txtPassword.Text, SSLCheck);
mail.Connect();
mail.Login();
Aspose.Network.Pop3.Pop3MessageInfoCollection info = new Pop3MessageInfoCollection();
info = mail.ListMessages();
int MessageCount = info.Count;

The exception I am getting at the ListMessages() is:
Length cannot be less than zero.
Parameter name: length

Thank you for any help you can provide. I am going to revert to a different version of Aspose.Network and write up the other issue as well.

Rick

Hi Rick,

We are looking into this issue. I have also added it in our issue tracking system (ID: 14367). We will notify you when we make some progress to fix it. Sorry for the inconvenience.

Thank you, I did some more research and I have a sample I put together that shows the issue. I tried this on google as well and got a different issue, on gmail, the list messages method never seemed to return at all.

I also tried a different method to get the messages by getting message headers but that was unseccessful as well.

Hi,

Could you please call ListMessages() method as follows:

info = mail.ListMessages(Pop3ListFields.SequenceNumber);

This will only get sequence numbers of messages. It might be due to the large number of emails in Inbox or Archive folder that the method is not returning at all. Please test the above statement and check if it returns without any exception/error.

This works, strange. This is a brand new mailbox (created for this test) and only has a couple of messages and no archive. I think I can make all of this work now, I will let you know if I have further issues.

OK, I thought that would all be fine but now it works ok if I have new emails but if my mailbox is empty, it the listMessages method fails with a null reference exception. I could probably do a try catch around this and handle the exception but I would expect this to return an empty Pop3messagecollection.

Let me know if this is expected behavior,

Rick

Yes, it throws exception currently. We will do some analysis and try to adopt the best approach.

Exception is fine for now, I already caught the exception so all is good now.

thank you for the workaround, this should work just fine

Rick

The issues you have found earlier (filed as 14652) have been fixed in [this update ](http://www.aspose.com/community/files/51/.net-components/aspose.network-for-.net/entry229369.aspx).

This message was posted using Notification2Forum from Downloads module by aspose.notifier.