Send email from ASP. NET page

Source: Internet
Author: User
We often see that you can post comments on some blog pages and notify the moderator via email (for example, our blog Park). So how can I use Asp.net to send emails? We can achieve this with the powerful class libraries provided by. net.

First, we need to introduce the system. Web. Mail namespace.

Create an instance of the mailmessage class. See belowCode:

1' create an instance
2dim objmm as new mailmessage ()
3
4 'set its properties
5objmm. To = "someone@someaddress.com"
6objmm. From = "someoneelse@someotheraddress.com"
7objmm. Cc = "someone2@someaddress.com"
8objmm. bcc = "someoneElse@someaddress.com"
9
10' sent in text format
11objmm. bodyformat = mailformat. Text
12' or sent in HTML Format
13objmm. bodyformat = mailformat. html
14
15' set mail priority
16objmm. Priority = mailpriority. Normal
17
18 'set theme
19objmm. Subject = "Hello there! "
20' mail body
21objmm. Body = "Hi! "& Vbcrlf &" How are you doing? "
22


'Finally, use the static method of the smtpmail class to send smtpmail. Send (objmm)

Some email servers need to authenticate the email again when sending the email (generally to prevent the spread of spam mail), for example, 163 free mailbox, if it is a version later than. net1.1, you can add:

Objmm. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); // Basic Authentication
Objmm. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendusername", "your_username_here"); // set your Username
Objmm. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendpassword", "your_password_here"); // set your password

In ASP. net2.0, The mailmessage class has been moved to the system. net. Mail namespace. For details about how to send emails, see:
Http://aspnet.4guysfromrolla.com/articles/072606-1.aspx
Http://aspnet.4guysfromrolla.com/articles/080206-1.aspx
Sending HTML mail with embedded image in. net

In addition, we will introduce a website dedicated to system. Web. mail:
Http://www.systemwebmail.com/default.aspx

For. net2.0, visit the system. net. Mail URL:

Http://www.systemnetmail.com/


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.