Free Support Forum - aspose.com

Parameter name: Username should not be null

I just downloaded Aspose.Network Version 3.8.0.0 and I created a simple .Net 2.0 console app to email out a test message.

Here is the code snippet:

//Create the MailMessage Instance
MailMessage msg = new MailMessage("user@somecompany.com","user@somecompany.com","Test","hello, how are you?");

//Send it
SmtpClient client;
client = new SmtpClient("localhost");
try
{

client.Send(msg);

}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadLine();
}

When you don't specify a username in the SmtpClient object, then following error occurs:

Value cannot be null.
Parameter name: Username should not be null

This is a problem. Can you review this and see if it's a problem?


Followup:

if you set client.AuthenticationMethod = SmtpAuthenication.None then you do not get the error and the message is sent.

Hello,

The exception is thrown when you don't set the username for the smtp connection to the server.

Thanks