This article illustrates the many possibilities of email in ASP.NET, covering the contents such as Email format, priority, accessories, and email codes.
ASP.NET is given a new object that sends Email, named SMTPMAIL. When you send email from the ASP.NET page using the SMTPMAIL object, you can follow the steps below:
Contains the namespace required to be related to the category of the message; illustrate an information object, set the property; send an email using the SMTPMail object instance.
Now let's take another step in studying the process from an ASP.NET page from an ASP.NET page. We use VB to show this example, and will eventually contain the full code of VB and C #.
Step 1: Contains Namespace
In the ASP.NET page, the System.Web.util namespace is introduced, and all objects that email must be sent in this namespace. These objects are:
SMTPMAIL: Represents mail system for transmitting email. MailMessage: On behalf of a message, its property includes the sender address, the recipient address, and the like. MailFormat: Represents information format: HTML, text, etc. MaiLattachment: represents an Email attachment. Mailencoding Enum: represents any code representing Base64 or UUENCODE. Value range: base64, uuencodemailpriority enum: Used to set priority for information. The value is: high, low, general. <% @Import namespace = "system.web.util"%>
Step 2: Explain the MailMessage object
Use the following statements to illustrate the MailMessage object:
Dim Mailobj As New MailMessage
Prepare emails with the properties of the MailMessage object. The MailMessage object has the following properties:
From: sender's email address to: Recipient's Email address Subject: Email's topic Body: Email's body CC: Email Cc recipient list BCC: Email Dark recipient list priority: information Priority: High, low or general fodyencoding: Information body encoding, if any, is Base64 or UuEncodeBodyFormat: Information Format: HTML or TextAttachments: A list of MaiLattachments attached to Email, mainly a reference to this object collection
The following code demonstrates the method of using the MailMessage object property, which represents an information that will be created in this example, this information is sent to send it with a SMTPMAIL object. In the example, Mailobj references an exemplary information object:
Mailobj.From = "abc@mydomain.com" mailobj.to = request.form ("to") mailobj.subject = "Subject of the mail" mailobj.body = "Message of the mail"
Step 3: Send Email
At this time, we can send an email using the SMTPMail object's Send method:
SMTPMAIL.SEND (Mailobj)
Full instance
Finally, we combine the above explanations in a complete example. To illustrate all the possibilities to send an email with ASP.NET, we also contain some "tips". Here is a complete example using VB.NET:
<% @ page language = "VB"%> <% @ Import namespace = "system.web.util"%>