This is what the error says and line 26 is where it says client.Send(message);
at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode) at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at ContactUsForm.send_Click(Object sender, EventArgs e) in d:\10Ap\prototype\ContactUsForm.aspx.cs:line 26
What I have tried:
This is the code i'm using
public partial class ContactUsForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void send_Click(object sender, EventArgs e)
{
try
{
MailMessage message = new MailMessage(from.Text, to.Text, subject.Text, body.Text);
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("smajwegmail.com", "Password here");
client.Send(message);
status.Text = "Mail was send successfully...!";
from.Text = "";
to.Text = "";
subject.Text = "";
body.Text = "";
}
catch (Exception ex)
{
status.Text = ex.StackTrace;
}
}
}