Other properties of MailMessage that you may need to use include
AlternateViews, BodyEncoding, DeliveryNotificationOptions, Headers,
Priority, ReplyTo, Sender, and SubjectEncoding.
The From field has the MailAddress type, representing an email address. The To,
CC, and Bcc properties are of the MailAddressCollection type, representing a
collection of MailAddress objects.
As you can see, there are lots of classes and properties that let you define email
messages. However, to be able to send these messages, you need access to a SMTP
server.
The standard email protocol of the Internet is Simple Mail Transfer Protocol
(SMTP). When you use ASP.NET to send an email, the message is relayed
through one or more SMTP servers on the way to its final destination. Most ISPs
provide an SMTP server for customers’ use; alternatively, if you’re using IIS, you
can make use of Windows’ built-in SMTP Server.
Configuring the SMTP Server
IIS Only
If you’re not using IIS, or you have access to an external SMTP server, you
can choose to skip this section.
In order to send an email, you need to connect to an SMTP server. On Windows,
an SMTP server is included with IIS, and you’ll need to configure this server if
you want to send email from ASP.NET. First, you need to make sure that the
SMTP service is running. Open the IIS applet to check its status. If the server is
stopped, you can right-click its icon and select Start to start it, as shown in Fig-
ure 14.13.
If the SMTP server entry doesn’t appear, you’ll need to install it using the process
outlined below. Note that the SMTP server is a component of IIS, so if you
haven’t installed IIS (or if your Windows version doesn’t support IIS, as is the
case with Windows XP Home) you won’t be able to install the SMTP server.
1.
Launch the Add or Remove Programs applet in Control Panel.
2.
Click Add/Remove Windows Components.
3.
Select the Internet Information Services item, and click Details….
595
Configuring the SMTP Server