WebMail Helper
The WebMail helper makes it easier to send mail, which sends mail from a WEB application in accordance with the SMTP (Simple Mail Transfer Protocol Easy Message Transfer Protocol).
Prerequisites: Email Support
To demonstrate how to use e-mail, we will create an input page that allows the user to submit a page to another page and send a message about the support issue.
First: Edit your AppStart page
If you have already created the Demo application in this tutorial, you already have a page called _appstart.cshtml, which reads as follows:
_
Appstart.cshtml@{websecurity.initializedatabaseconnection ("Users", "UserProfile", "UserId", "Email", true);
To start the WebMail helper, add the WebMail attribute shown below to your AppStart page:
_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";}
Attribute Explanation:
SmtpServer: The name of the SMTP server that is used to send e-mail.
Smtpport: The port that the server uses to send SMTP transactions (e-mail).
Enablessl: True if the server is encrypted using SSL (Secure Socket Layer).
UserName: The name of the SMTP e-mail account used to send e-mail.
PASSWORD:SMTP the password for your email account.
From: The e-mail message (usually the same as UserName) displayed in the address bar of the sender.
Second: Create an e-mail entry page
Then create an input page and name it email_input:
email_input.cshtml<! DOCTYPE html>
The purpose of entering the page is to phone information, and then submit the data to a new page that can send the information as an e-mail message.
Third: Create an email sending page
Then create a page to send the e-mail message to, and name it email_send:
email_send.cshtml@{//Read Inputvar customeremail = request["Customeremail"];var customerrequest = Request[" Customerrequest "];try{//Send email webmail.send (To:" someone@example.com ", Subject:" Help request from-"+ Customeremai L, Body:customerrequest); }catch (Exception ex) {<text> @ex </text>}}
"Recommended"
1. ASP. NET free Video Tutorials
2. Share the ASP. NET Learning Notes (1)--webpages Razor
3. Share the ASP. NET Learning Notes (2)--webpages Introduction
4. Share the ASP. NET Learning Notes (3) Webpages layout
5. Share the ASP. NET Learning Note (7) Webpages Object
6. Share the ASP. NET Learning Notes (5) global page AppStart and Pagestart
7. Share the ASP. NET Learning Note (8) Webpages Helper