Developing a mail delivery system using ASP.net

Source: Internet
Author: User
Tags format mail mailmessage visual studio
asp.net| Send mail

Nowadays, with the rapid development of Internet, many enterprises have built their own websites, which can be used to carry out e-commerce activities, such as releasing and managing the enterprise's own supply and demand information, and developing and managing the members of the enterprise. In addition to these, there is also a point is very important, is to all enterprises registered members to send e-mail, timely notify users of the company's latest news.

Microsoft has been introducing Visual Studio.NET for some time, and some users who used to use ASP to develop Web applications now slowly have an ASP to turn to the ASP.net platform. In order to be able to help some users who want to use asp.net to develop mail delivery system to successfully complete this function, we will discuss this issue together.

I. ASPX operating environment

Because the BETA1 and Beta2 two versions of Microsoft's published. NET Framework SDK are very different, this is an example of a Beta2 version.

Introduction of SMTP protocol

SMTP protocol, which is the abbreviation for Simple Mail Transfer Protocol (plain mail Transfer Protocol). General letter of the software, such as Outlook Express, Foxmail, etc. are used to send and relay mail.

Iii. name Space (NameSpace)

Describes the objects, properties, and methods used in the program in this article to use the namespace (NameSpace)-system.web.mail (referred to in the. NET Framework SDK Beta1 version, called System.Web.Util), to send messages.

1, objects (object)

The System.Web.Mail namespace is used to send messages with three objects, such as SmtpMail, MailMessage, and MailAttachment, as described below.

2, Attributes (propertiy)

The primary property of the System.Web.Mail namespace is the property of the MailMessage object, and the following table lists the names of the MailMessage object properties and their meanings:

Attribute names represent meaning

From sender address (source address)

To recipient address (destination system)

Subject message Headers

Priority message priority (High,low,normal)

Attachment Mail Attachment

BCC Dark Send Address

CC CC Address

Body message bodies

BodyFormat message Format (HTML format, text format)

Bodyencoding Encoding (Base64,uuencode)

3. Methods (method)

Send method, the message is sent through the Send method. There are two ways to call this method:

1 Smtpmail.send ("Source Address", "Destination Address", "subject", "content")

2) smtpmail.send (MailMessage)

Note: This is the second method of invocation.

Iv. Program source code (programming script language for vb.net)

<%@ Page language= "VB" runat= "Server"%>

<script runat= "Server" >

Sub Button1_Click (sender as Object, E as EventArgs)

Dim Strfrom,strto,strbcc,strcc,title,conttext

Strfrom =textbox1.text

Strto =textbox2.text

STRBCC =textbox3.text

STRCC =textbox4.text

Title =textbox5.text

Conttext =textbox6.text

Dim objmail as New MailMessage

Dim SMTP as New smtpmail

Smtp.smtpserver= "Smtp.163.com" defines the name of the server

Select Case Objmail

. From= Strfrom

. To= Strto

. Bcc= STRBCC

. Cc= STRCC

. subject= Title

. body= Conttext

. bodyformat= mailformat.html

. priority= Mailpriorty.high

End Select

Smtp.send (objmail)

End Sub

</script>

<body>

<form runat= "Server" >

<p>

Receiver: <asp:textbox id= "TextBox1" runat= "Server" >

</asp:TextBox>

</p>

<p>

Sender: <asp:textbox id= "TextBox2" runat= "Server" ></asp:TextBox>

</p>

<p>

Dark Send: <asp:textbox id= "TextBox3" runat= "Server" ></asp:TextBox>

</p>

<p>

CC: <asp:textbox id= "TextBox4" runat= "Server" ></asp:TextBox>

</p>

<p>

Topic: <asp:textbox id= "TEXTBOX5" runat= "Server" ></asp:TextBox>

</p>

<p>

Content: <asp:textbox id= "TextBox6" runat= "Server" ></asp:TextBox>

</p>

<p>

<asp:button id= "Button1" runat= "Server"

text= "Send" >

</asp:Button>

</p>

</form>

</body>

V. Summary

In the past, when Microsoft did not launch the ASP.net, we used ASP to do a mail delivery system is very complicated, is a very difficult thing, now good, Microsoft has recently launched the. NET Framework SDK Beta2 version, The use of System.Web.Mail namespaces is a powerful class library, making it easier for us to do this work.



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.