Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

System.Web.Mail and the pickup directory

0.00/5 (No votes)
28 Dec 2004 1  
This article describes how to use System.Web.Mail with the SMTP server's pickup directory.

Introduction

When you send e-mail using System.Web.Mail and the local SMTP server, you can avoid the roundtrip to the network and use the pickup directory.

The Code

You can easily update your existing code. For example take this:

eMail = new MailMessage();
eMail.BodyFormat = MailFormat.Text;
eMail.To = "recipients@codeproject.com";
eMail.Body = _Body;
eMail.From = _SendFrom;
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(eMail);

Just add two lines of code and you are done:

eMail = new MailMessage();
eMail.BodyFormat = MailFormat.Text;
eMail.To = "recipients@codeproject.com";
eMail.From = _SendFrom;
eMail.Body = _Body;
SmtpMail.SmtpServer = "localhost";
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusing"]  = 1;
eMail.Fields[
  "http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"] = 
  "C:\\Inetpub\\mailroot\\Pickup";
SmtpMail.Send(eMail);

Conclusion

Especially if you want to send loads of e-mails, like in a newsletter application, you should keep this in mind.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here