Free Support Forum - aspose.com

Pop3Client.ListMessages throws NullReferenceException

client.ListMessages throws NullReferenceException: Object reference not set to an instance of an object.
See below forthe code, the exception and the log file.

The code

static void test3()
{
    var client = new Pop3Client
    {
        Host = "mail.zxcs.nl",
        Port = 995,
        SecurityOptions = SecurityOptions.SSLImplicit,
        UseAuthentication = true,
        Username = "****************************",
        Password = "****************************"
    };

    client.LogFileName = "aspose.log";
    client.EnableLogger = true;

    var connection = client.CreateConnection();
    var messages = client.ListMessages(connection, Pop3ListFields.IdOnly);
}

The exception

Aspose.Email.AsposeException
  HResult=0x80131500
  Message=Object reference not set to an instance of an object.
  Source=Aspose.Email
  StackTrace:
   at   .      (IAsyncResult )
   at   .      ()
   at Aspose.Email.Clients.EmailClient. (IAsyncResult )
   at Aspose.Email.Clients.Pop3.Pop3Client.  (IAsyncResult )
   at Aspose.Email.Clients.Pop3.Pop3Client.ListMessages(IConnection connection, Pop3ListFields fields, Boolean closeTransaction, MailQuery query)
   at Aspose.Email.Clients.Pop3.Pop3Client.ListMessages(IConnection connection, Pop3ListFields fields)
   at TestMail.Program.test2() in C:\Users\HendrikRomkes\source\repos\TestMail\TestMail\Program.cs:line 51
   at TestMail.Program.<Main>d__0.MoveNext() in C:\Users\HendrikRomkes\source\repos\TestMail\TestMail\Program.cs:line 12

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
NullReferenceException: Object reference not set to an instance of an object.

The logfile

-------------------------------------------------------------------------------
--- Aspose.Email for .NET [21.3.0.0] POP3 Client diagnostic log
--- 
--- Started: 15-4-2021 09:28:28
-------------------------------------------------------------------------------


-------------------------------------------------------------------------------
--- Aspose.Email for .NET [21.3.0.0] POP3 Client diagnostic log
--- 
--- Started: 15-4-2021 09:28:29
-------------------------------------------------------------------------------

Pop3 client[2|15-4-2021 09:28:29]: 
Pop3 client[2|15-4-2021 09:28:29]: 
15-4-2021 09:28:29	
                  	
Pop3 client[2|15-4-2021 09:28:29]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Connect to: mail.zxcs.nl:995 SecurityOptions.SSLImplicit <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Pop3 client[2|15-4-2021 09:28:29]: 
15-4-2021 09:28:29	
                  	
Pop3 client[2|15-4-2021 09:28:29]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Environment version: 3.1.13 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Pop3 client[2|15-4-2021 09:28:29]: 
15-4-2021 09:28:29	
                  	
Pop3 client[2|15-4-2021 09:28:29]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> OS version: Microsoft Windows NT 6.2.9200.0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Pop3 client[2|15-4-2021 09:28:29]: 
15-4-2021 09:28:29	
                  	
Pop3 client[2|15-4-2021 09:28:29]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Assembly title: Aspose.Email for .NET <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Pop3 client[2|15-4-2021 09:28:29]: 
15-4-2021 09:28:29	
                  	
Pop3 client[2|15-4-2021 09:28:29]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Assembly version: 21.3.0.0 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Pop3 client[2|15-4-2021 09:28:29]: 
15-4-2021 09:28:29	
                  	
Pop3 client[2|15-4-2021 09:28:29]: 
Pop3 client[2|15-4-2021 09:28:29]: 
15-4-2021 09:28:29	
                  	
Pop3 server[2|15-4-2021 09:28:30]: +OK POP3 ready
Pop3 server[2|15-4-2021 09:28:30]: 
15-4-2021 09:28:30	
                  	
Pop3 client[2|15-4-2021 09:28:30]: CAPA
Pop3 client[2|15-4-2021 09:28:30]: 
15-4-2021 09:28:30	
                  	
Pop3 server[2|15-4-2021 09:28:30]: +OK Capability list follows
Pop3 server[2|15-4-2021 09:28:30]: TOP
Pop3 server[2|15-4-2021 09:28:30]: USER
Pop3 server[2|15-4-2021 09:28:30]: SASL PLAIN LOGIN
Pop3 server[2|15-4-2021 09:28:30]: .
Pop3 server[2|15-4-2021 09:28:30]: 
15-4-2021 09:28:30	
                  	
Pop3 client[2|15-4-2021 09:28:30]: USER ------removed------
Pop3 client[2|15-4-2021 09:28:30]: 
15-4-2021 09:28:30	
                  	
Pop3 server[2|15-4-2021 09:28:30]: +OK
Pop3 server[2|15-4-2021 09:28:30]: 
15-4-2021 09:28:30	
                  	
Pop3 client[2|15-4-2021 09:28:30]: PASS ************
Pop3 client[2|15-4-2021 09:28:30]: 
15-4-2021 09:28:30	
                  	
Pop3 server[2|15-4-2021 09:28:30]: +OK Logged in.
Pop3 server[2|15-4-2021 09:28:30]: 
15-4-2021 09:28:30

@hromkes,
Thank you for your request. Unfortunately, I haven’t managed to reproduce the error. I logged the issue in our tracking system with ID EMAILNET-40193. Our development team will investigate it. I will inform you about any progress.

The error does not occur for all mail servers.
Office 365 works fine.

Unfortunately, the client cannoit wait, so for now, I replaced the aspose pop3 client with MailKit/MimeKit, which does not have any issues with this particular mail server.

@hromkes,
We are doing our best to figure out this case.

@hromkes,
Unfortunately, our development team hasn’t managed to reproduce the error. Could you share test credentials for this email server for testing this issue on our side, please?

Unfortunately, I dont have test credentials.
An email adress for the provider can be created via the link below:

https://www.vimexx.nl/email/emailadres

I’m not going to spend more time on this, because I have a working solution with MailKit now.

@hromkes,
Thank you for the additional information. I passed it to our development team. It is a pity that we did not solve the problem quickly.