11.7. Send E-mail Using SMTP

Problem

You need to send e-mail using an SMTP server.

Solution

Use the SmtpClient and MailMessage classes in the System.Net.Mail namespace.

How It Works

An instance of the SmtpClient class provides the mechanism through which you communicate with the SMTP server. You configure the SmtpClient using the properties described in Table 11-3.

Table 11.3. Properties of the SmtpClient Class
PropertyDescription
ClientCertificatesGets a System.Security.Cryptography.X509Certificates.X509CertificatesCollection to which you add the certificates to use for communicating with the SMTP server (if required).
CredentialsGets or sets an implementation of the System.Net.ICredentialsByHost interface that represents the credentials to use ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.