Share the ASP (NET) learning Note (webpages Email)

Source: Internet
Author: User
Tags email account mail account

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.