Ajad Patel

Ajad Patel

  • NA
  • 69
  • 494

Email sending problem

Dec 28 2017 2:53 AM
Hello sir 
 
 I am sending mail during I get error which I mention below.
 
 "Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this serve
 
And My code is:
 
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
SmtpClient smtpClient = new SmtpClient();
string msg = string.Empty;
try
{
MailAddress fromAddress = new MailAddress(SenderEmail);
message.From = fromAddress;
message.To.Add(Email);
message.Subject = " Registration Details";
message.IsBodyHtml = true;
// message.Body = "Email ID is: " + Email;
message.Body = "Email ID is: ";
smtpClient.Host = HostName; 
smtpClient.Port = PortNumber; 
smtpClient.EnableSsl = false;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential(UserName, Password);
smtpClient.Send(message);
}
catch (Exception ex)
{
}
 

Answers (6)