无法发送联系人......? [英] Unable to Send Contact...?

查看:71
本文介绍了无法发送联系人......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抛出了'System.Web.HttpUnhandledException'类型的异常。



错误:无法发送联系人 - SMTP服务器需要安全连接或客户端是未经过身份验证。服务器响应为:5.7.0必须首先发出STARTTLS命令。 iq10sm53816480pbc.14 - gsmtp







protected void ImageButton_Submit_Click(object sender,ImageClickEventArgs e)

{

尝试

{

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 =谢谢 - 您的消息已发送。;



}

catch(异常exp)

{

抛出新异常(错误:无法发送联系人 - + exp.Message.ToString (),exp);

}



}



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

}

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>

推荐答案

这是自我解释 - 您没有在SMTP服务器上使用任何可以启用发送的凭据...

这里有一个很好的解决问题:

使用C#中的SMTP发送电子邮件 [ ^ ]
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#[^]


这篇关于无法发送联系人......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆