Latest web development tutorials

ASP.NET 웹 페이지 이메일

웹 메일 도우미 - 많은 유용한 ASP.NET 웹 도우미 중 하나.


웹 메일 도우미

웹 메일 도우미는 쉽게 SMTP (단순 메일 전송 프로토콜 단순 메일 전송 프로토콜)에 따른 웹 응용 프로그램에서 메일을 보낼 수있는 메시지를 전송 할 수 있습니다.


전제 조건 : 이메일 지원

전자 메일을 사용하는 방법을 설명하기 위해, 우리는 사용자가 다른 페이지에 페이지를 제출 할 수있는 입력 페이지를 작성하고, 지원 문제에 대한 메시지를 보내드립니다.


첫째 : 당신의 AppStart 페이지를 편집

당신이 데모 응용 프로그램을 만든 경우 다음과 같이이 튜토리얼에서는, 당신은 이미 _AppStart.cshtml라는 페이지가 있습니다 :

_AppStart.cshtml

@{
WebSecurity.InitializeDatabaseConnection("Users", "UserProfile", "UserId", "Email", true);
}

다음과 같이 페이지 AppStart 웹 메일 속성을 증가시키기 위해, 웹 메일 도우미를 시작하려면 :

_AppStart.cshtml

@{
WebSecurity.InitializeDatabaseConnection("Users", "UserProfile", "UserId", "Email", true);
WebMail.SmtpServer = "smtp.example.com";
WebMail.SmtpPort = 25;
WebMail.EnableSsl = false;
WebMail.UserName = "[email protected]";
WebMail.Password = "password-goes-here";
WebMail.From = "[email protected]";

}

속성 설명 :

은 SmtpServer : 전자 메일 SMTP 서버 이름을 전송합니다.

SmtpPort : 트랜잭션 (이메일) 포트를 보내는 데 사용되는 SMTP 서버입니다.

EnableSsl : 서버가 SSL (보안 소켓 레이어 보안 소켓 레이어) 암호화를 사용하는 경우, 값이 true입니다.

사용자 이름 : 전자 메일 SMTP 전자 메일 계정을 보내는 데 사용되는 이름.

비밀번호 : 비밀번호 SMTP 전자 메일 계정.

보낸 사람 : 전자 메일 보낸 사람의 주소 표시 줄 (일반적으로 동일한 사용자 이름).


둘째 : 전자 메일 입력 페이지 만들기

그런 다음 Email_Input를 입력 페이지를 작성하고 이름 :

Email_Input.cshtml

<!DOCTYPE html>
<html>
<body>
<h1>Request for Assistance</h1>

<form method="post" action="EmailSend.cshtml">
<label>Username:</label>
<input type="text name="customerEmail" />
<label>Details about the problem:</label>
<textarea name="customerRequest" cols="45" rows="4"></textarea>
<p><input type="submit" value="Submit" /></p>
</form>

</body>
</html>

범용 입력 페이지 휴대 전화이며, 다음 전송 된 새 페이지 메일로 사용될 수있는 정보에 대한 데이터를 전송.


셋째, 전자 메일 보내기 페이지 만들기

그런 다음 전자 메일을 보내기위한 페이지를 생성하고 Email_Send 이름 :

Email_Send.cshtml

@{ // Read input
var customerEmail = Request["customerEmail"];
var customerRequest = Request["customerRequest"];
try
{
// Send email
WebMail.Send(to:"[email protected]", subject: "Help request from - " + customerEmail, body: customerRequest );
}
catch (Exception ex )
{
<text>@ex</text>
}
}

전자 메일 정보를 전송하는 ASP.NET 웹 페이지 응용 프로그램에 대한 자세한 내용은 문의하시기 바랍니다 : 웹 메일 개체 참조 .