電子メールアドレス、送信ボタン、エラーラベルのテキストボックスを持つテストページを作成しました。私はdon`ASP.NETからクライアントに電子メールを送信できない
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: The remote name could not be resolved: 'smtp.google.com' at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at email.btnSend_Click(Object sender, EventArgs e) in d:\WebDev\Test\email.aspx.cs:line 28
しかし、それは私のために働いていない:それは私に示して完全なエラーがある
try
{
MailMessage mail = new MailMessage("[email protected]", (string)txtEmail.Text);
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.google.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
lblError.Text = "Message sent!";
}
catch (Exception ex)
{
lblError.Text = ex.ToString();
}
:ここ
は、私はフォーラムで、ここで見てきたC#コードであります何をすべきか知っています!
「それはありません「働く」という意味ですか?エラーメッセージが表示されますか? –
あなたはどんなエラーがありますか? – user1666620
申し訳ありませんが、私は質問本体に完全なエラーを追加しました – D4NieLDev