-1

NetworkCredential(address, pass) returns null on clients ipad, but not on my test machines while using the same address and pass

SmtpClient smtpServer = new SmtpClient(mailServer);

smtpServer.UseDefaultCredentials = false;

smtpServer.Credentials = new System.Net.NetworkCredential(address, pass) 
    as ICredentialsByHost;

if (smtpServer.Credentials == null) {
    AV.Error("Mail credentials null -> email='" + address + "' pass='" + pass + "'");
}
else {
    send the email
}

The code runs fine on my test pc and my test ipad. On my clients iPad, it throws the error message because credentials are null. I can see its using the exact same address and pass. I have no idea why it would do that from their ipad, but not from mine.

user1803763
  • 9
  • 1
  • 4

1 Answers1

1

Setting UseDefaultCredentials =false should work for you. Add below lines of code.

not setting UseDefaultCredentials =false before credentials line sometimes nullify the object which is very strange.

SmtpClient smtpServer = new SmtpClient(mailServer);

smtpServer.UseDefaultCredentials =false;

smtpServer.Credentials = new System.Net.NetworkCredential(address, pass) as ICredentialsByHost;