ASP.NET Web Pages - WebMail 帮助器
WebMail 帮助器 - ASP.NET Web 。
WebMail 帮助器
WebMail web 使用 SMTP 。
脚本: Email 支持
件。
您的 AppStart 页面
中的 DEMO 的 _AppStart.cshtml 页面:
_AppStart.cshtml
@{
WebSecurity.InitializeDatabaseConnection("Users", "UserProfile", "UserId", "Email",
true);
}
WebMail 向您的 AppStart 下 WebMail 属性:
_AppStart.cshtml
@{
WebSecurity.InitializeDatabaseConnection("Users", "UserProfile", "UserId", "Email",
true);
WebMail.SmtpServer = "smtp.example.com";
WebMail.SmtpPort = 25;
WebMail.EnableSsl = false;
WebMail.UserName = "support@example.com";
WebMail.Password = "password-goes-here";
WebMail.From = "john@example.com";
}
SmtpServer: 使用的 SMTP 称。
SmtpPort: 发送 SMTP transactions (电邮) 器端口。
EnableSsl: True SSL (Secure Socket Layer) 加密。
UserName: 用的 SMTP email 。
Password: SMTP 密码。
From: 出现在 from 与 UserName 相同)。
面
为 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:"someone@example.com",
subject: "Help request from - " + customerEmail,
body: customerRequest );
}
catch (Exception ex )
{
<text>@ex</text>
}
}
关从 ASP.NET Web Pages 参阅:WebMail 册。