Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Exception of type 'System.Web.HttpUnhandledException' was thrown.

ERROR: Unable to Send Contact - The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. iq10sm53816480pbc.14 - gsmtp



protected void ImageButton_Submit_Click(object sender, ImageClickEventArgs e)
{
try
{
MailMessage mMailMessage = new MailMessage();

mMailMessage.From = new MailAddress(HttpUtility.HtmlEncode(TextBoxEmail.Text));
mMailMessage.To.Add(new MailAddress("MyAccount@gmail.com"));

// mMailMessage.Bcc.Add(new MailAddress(bcc));
// mMailMessage.CC.Add(new MailAddress(cc));

mMailMessage.Subject = "From:" + HttpUtility.HtmlEncode(TextBoxYourName.Text) + "-" + HttpUtility.HtmlEncode(TextBoxSubject.Text);
mMailMessage.Body = HttpUtility.HtmlEncode(EditorEmailMessageBody.Content);
mMailMessage.IsBodyHtml = true;
mMailMessage.Priority = MailPriority.Normal;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.Send(mMailMessage);
LabelMessage.Text = "Thank You - Your Message was sent.";

}
catch (Exception exp)
{
throw new Exception("ERROR: Unable to Send Contact - " + exp.Message.ToString(), exp);
}

}

XML
my web config code...
mailSettings
<smtp from="MyAccount@gmail.com">
<network host="smtp.gmail.com" password="MyAccountpassword" port="587">
userName="MyAccount@gmail.com"
</network></smtp>
Posted
Updated 11-Feb-14 4:22am
v3

1 solution

It's self explanatory - you does not used any credentials on the SMTP server that can enable sending...
There is a nice - solved - question here:
Send Email using SMTP in C#[^]
 
Share this answer
 
Comments
Member 10533469 11-Feb-14 10:26am    
Im using the tailspin works, and i follow all the tutorials and videos and I think I have something not configure...
Kornfeld Eliyahu Peter 11-Feb-14 10:29am    
Id don't know your tutorials but certainly you missing this part:
SmtpServer.Credentials = ...
Help yourself and read the solution in the other question...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900