成免费的crm,久久国产精品新农夫导航新妓网,恋夜秀场全部视频安卓手机,女校花强奷在线播放A级

ASP.NET Web Pages Email

asp.net web pages - webmail 幫助器

webmail 幫助器 - 眾多有用的 asp.net web 幫助器之一。

webmail 幫助器

webmail 幫助器讓發送郵件變得更簡單,它按照 smtp(simple mail transfer protocol 簡單郵件傳輸協議)從 web 應用程序發送郵件。

前提:電子郵件支持

為了演示如何使用電子郵件,我們將創建一個輸入頁面,讓用戶提交一個頁面到另一個頁面,并發送一封關于支持問題的郵件。

第一:編輯您的 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 事務(電子郵件)的端口。

enablessl: 如果服務器使用 ssl(secure socket layer 安全套接層)加密,則值為 true。

username: 用于發送電子郵件的 smtp 電子郵件賬戶的名稱。

password: smtp 電子郵件賬戶的密碼。

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 對象參考手冊。


相關文章