I am using following code to send email. The Code works correctly in my local Machine. But on Production server i am getting the error message
var fromAddres
A comment from Tomasz Madeyski is what fixed my problem... he tells that exists a bug on SetDefaultCredential, him says:
"The issue is that in UseDefaultCredentials setter there is this code: this.transport.Credentials = value ? (ICredentialsByHost) CredentialCache.DefaultNetworkCredentials : (ICredentialsByHost) null; which overrides credentials set by Credentials setter. For me it looks like SmtpClient's bug"
if you put smtpClient.UseDefaultCredentials = false
after set credentials... this line set to null those credentials...