In this article, explain the use of ASP.NET to send emails, including selecting email format, priority, accessories, and email. Now let's gradually explore the use of ASP.NET to send an email. We will use VB to explain examples, but our last code includes VB and C #. Step1: Includes namespace System.Web.util namespace in ASP.NET. This namespace contains all the necessary objects to send emails. Objects are: Object Summary SMTPMAIL represents the mail system. send email. MailMessage message, such as sender addresses, recipient addresses, etc. MailFormat format, email format - HTML, text, and so on MaiLattachment Represents Email attachment Mailencoding Enum represents any end code such as Base64 or uuencode. MailPriority Enum sets email priority. Value: High, low, normal <% @Import namespace = "system.web.util"%> OK The first section has completed step 2: MailMessage object example declares MailMessage object. Dim Mailobj AS New MailMessage MailMessage Object Properties: Property Description from sender's address to recipient's address Subject Mail Topic Body Mail Text CC Mail Copy Acceptor Address BCC Mail Copy Acceptors Address than display in Mail (Double) Priority Mail Priority BodyEncoding E-code BodyFormat Mail format, HTML, or text attachments Mail attachment The following code snippets will display the MailMessage object. Mailobj.From = "abc@mydomain.com" Mailobj.to = Request.form ("to") mailobj.subject = "Subject of the mail" mailobj.body = "message of the mail" Send Mail Use SMTPMail Object SEND Method .
The following code snippet is used to send mail smtpmail.send (mailobj) VB.NET (Mailobj) VB.NET full source code <% @ page language = "VB"%> <% @ Import namespace = "system.web.util"%>