S
smtaqi
Guest
wn votefavoriI need to send email using NTLM, currently, I'm using the following code to send email
SmtpClient objSmtpClient;
System.Net.NetworkCredential objNetworkCredential;
objSmtpClient = new SmtpClient("10.xxx.xxx.xxx", 587);
objSmtpClient.EnableSsl = true;
objNetworkCredential = new System.Net.NetworkCredential(userName, password);
try
{
string to = txtto.Text;
MailMessage objMailMessage = new MailMessage();
objMailMessage.From = new MailAddress("from@email.com", "sendername");
objMailMessage.To.Add(new MailAddress("to@email.com"));
objMailMessage.Subject = "subject";
objMailMessage.Body = "body";
objMailMessage.IsBodyHtml = true;
objSmtpClient.EnableSsl = true;
objSmtpClient.UseDefaultCredentials = true;
objSmtpClient.Credentials = objNetworkCredential;
objSmtpClient.Send(objMailMessage);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " INNER EXCEPTION > "+ex.InnerException +" DATA > "+ex.Data);
}
The Above code works if I try to change the port to 25 and EnableSSL to false, But when I try to send it using 587 and setting EnableSSL to true it doesn't work.
I'm getting the following error, sometimes I get an Invalid Certificate error.
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated.
I am also getting this error
I talked with the IT team they installed a tool on my pc to check email, using that tool email was sent successfully.
The following are the setting which he applied in that tool
I think the problem is with Authentication, how can I force to use NTLM
Can someone please help
www.techgulf.blogspot.com
Continue reading...