
527
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Chapter 27Mail Namespace
27
The System.Web.Mail
Namespace
The System.Web.Mail namespace allows you to send email messages from your
ASP.NET application. This capability can use the built-in SMTP service included
with IIS or an arbitrary SMTP server, and is similar to the CDO component used
in traditional ASP development. The SMTP service in IIS maps its Inbox and
Outbox to directories on the server. Message transfer is handled so that the
Outbox is always empty and the Inbox never has an incoming queue. Note that in
order to use these features, you must correctly configure the default SMTP server
in IIS Manager so that it will relay messages to the Internet. If you do not take this
step your mail will never be delivered, even though no exceptions will be raised in
your code.
Messages and attachments are encapsulated in MailMessage and MailAttachment objects
and sent using the SmtpMail helper class, which provides a single Send( ) method.
Figure 27-1 shows the types in this namespace.
Figure 27-1. The System.Web.Mail namespace
implementsextends
KEY
System System.Web.Mail
Abstract ClassClass Interface
Sealed
Object MailAttachment
MailMessage
SmtpMail