0
연락처 페이지의 코드에서 전자 메일 설정을 구성하면 유효성 검사 컨트롤이 더 이상 작동하지 않는 것 같습니다. 전자 메일 주소의 유효성을 검사하기 위해 필드 유효성 검사와 정규식 유효성 검사가 필요했습니다. 유효성 검사는 System.Net.Mail을 사용해야하는 전자 메일 구성을 삽입하기 전에 click 이벤트에서 작동합니다.System.Net.Mail을 사용할 때 유효성 검사 기능이 없음
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Contact : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To.Add("[email protected]");
mail.From = new MailAddress(EmailAddressTextBox.Text);
mail.Subject = SubjectTextBox.Text;
mail.Body = "email address: " + EmailAddressTextBox.Text + "<br />" + MessageTextBox.Text;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("[email protected]", "password");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Port = 587;
smtp.Send(mail);
EmailAddressTextBox.Text = String.Empty;
SubjectTextBox.Text = String.Empty;
MessageTextBox.Text = String.Empty;
}
}