Develop mail sending system using ASP.NET
Today, with the rapid development of the Internet, many companies have arracted their own websites, used to carry out e-commerce activities of enterprises, such as released, managed their own supply and demand information; members of the development and management enterprises. In addition to these, it is very important to send an email to all enterprise registered members, and inform the user's latest news. Microsoft has launched Visual Studio.net for some time, some netizens who used ASP development web applications, now slowly have ASP to stereot the ASP.NET platform. In order to help some netizens who want to use ASP.NET to develop mail sending systems to complete this feature, let's discuss this issue together. I. ASPX running environment This paper is a great difference due to the two versions of the Beta1 and Beta2 of Microsoft's released .NET Framework SDK, this article is explained as a CETA2 version. Second, SMTP Protocol Introduction The SMTP protocol is an abbreviation of Simple Mail Transfer Protocol. General sending software, such as Outlook Express, Foxmail, etc. are sent and transferred using this protocol.
Third, the namespace (Namespace) Introduction to the namespace (Namespace) -system.web.mail (in the .NET Framework SDK Beta1 version) provided in the program provided in this article. Objects, properties, and methods sent by emails. 1. Objects System.Web.mail namespaces are used to send mail objects with three objects such as SMTPMAIL, MailMessage, and MaiLattachment, and the specific roles are described below. 2, Property System.Web.mail Name Space's main properties, is the properties of the MailMessage object, the following table lists the name and its meaning of the MailMessage object property: The property name represents the meaning of the Source address (source address) to Receiver Address (Destination) Subject Mail Title Priority Mail Priority (High, Low, Normal) Attachment Email Accessories BCC Dark Address CC Cc Address Body Mail Body BodyFormat Mail Format (HTML Format, Text Format) BodyEncoding Code (Base64 , Uuencode 3, method (METHOD) SEND method, mail is sent through the Send method. There are two ways to call: 1) SMTPMAIL.SEND ("Source Address", "Destination Address", "Subject", "Content") 2) SMTPMAIL.SEND (MailMessage) Note: This article is the second call the way. Fourth, the program source code (programming scripting language is VB.NET) <% @ page language = "vb" 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 = name TextBox6.Text Dim objMail As new MailMessage Dim smtp As new SmtpMail Smtp.SmtpServer = "smtp.163.com" 'server is defined Select Case objMail .From = strFrom .To = strTo .Bcc = strBcc .Cc = strCc .Subject = Title .Body = contText .BodyFormat = mailformat.html .priority = mailpriorty.high End SMTP.SEND (OBJMAIL) End Sub script>