Asp. NET send email Complete instance

Source: Internet
Author: User
Tags mailmessage net send

This article illustrates the many possibilities of sending emails in, covering such aspects as email format, priority, attachment and email encoding.

Asp. NET is given a new object to send email, named SmtpMail. When you use the SmtpMail object to send e-mail from a page, you can follow these simple steps:

▲ contains the namespaces required for the class of the message;

▲ example an information object, set the attribute;

▲ send a message using the Send method of the SmtpMail object instance.

Now we're going to take a step-by-step look at the process of sending emails from a page. We use VB to illustrate this example, the final will include VB and C # complete code.

First step: Include namespaces

Introduce the System.Web.Util namespace in the page, which includes all the objects necessary to send an email. These objects are:

MailEncoding enum:代表Base64 或Uuencode的任何编码。取值范围:Base64、UUencode
MailPriority enum:用来为信息设置优先权。值为:高、低、一般。
<% @Import Namespace = "System.Web.Util" %>

Step Two: Example MailMessage object

Use the following statement to sample the MailMessage object:

Dim Mailobj as New MailMessage

Prepares the message with the properties of the MailMessage object. The MailMessage object has the following properties:

BodyFormat:信息的格式:Html 或text
Attachments:附加到email 的MailAttachment对象列表,主要就是对这个对象集合的一个引用

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: 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.