
Figure 1 - The Smtp Mailing Application
This is an article on how to use the Mail Components in .NET to create a simple application to send e-mail. You can also refer to Mahesh's article on this site for some additional details and understanding of Smtp Mail in .NET.
The Smtp Mail functionality is contained in the System.Web.Mail namespace and contains three classes:
System.Web.Mail Classes
Description
SmtpMail
Class used to send Mail via Windows 2000 SMTP services.
MailMessage
This class contains everything contained in an e-mail message. An instance of this can be sent by the SmtpMail class.
MailAttachment
This is a class representing an attachement to an email.
Table 1 - System.Web.Mail Namespace
The SmtpMail Class gives you two static methods to send mail: the quick and easy way, and the more detailed way.
SmtpMail.Send(FromString, ToString, SubjectString, MessageString)
or
SmtpMail.Send(aMailMessage)
I opted to send email using the MailMessage object in this example because you can send a lot more information. Some of the properties of the MailMessage Object are shown below:
MailMessage Property
Description
From
who the email is from
To
who the email is to
Cc
who the email is copied to
Bcc
who the email is copied to without seeing the recipients
Attachments
A collection of Attachments to the email
Subject
Subject of the email
Body
Message Body of the email
BodyFormat
The format of the Message Body (Currently Text or Html)
Priority
MailPriority of the Message (High, Low, or Normal)
Loading





Join the conversation! Your thoughts help the community grow.