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)
{
}

Shweta LodhaRank #31 · 39.8K reputationPosted Dec 27, 2017, 10:44 PM EST
Ankit SharmaRank #141 · 16.1K reputationPosted Dec 27, 2017, 10:07 PM EST
Ramesh PalanivelRank #372 · 6.8K reputationPosted Dec 27, 2017, 10:14 PM EST
Rajeesh MenothRank #118 · 18.4K reputationPosted Dec 27, 2017, 10:48 PM EST
Rajkiran SwainRank #165 · 14.4K reputationPosted Dec 27, 2017, 11:22 PM EST
Laxmidhar SahooRank #383 · 6.6K reputationPosted Dec 28, 2017, 12:51 AM EST