次の方法で共有


About: System.Web.Mail (SWM)

API Type:  SMTP Sender
API Interface:  .NET Framework Namespace Classes.

Business Logic: Sending mail via SMTP.

Language Support: .NET Languages only.

Direct Property Access:  N/A.

Product Versions: All versions of .NET Framework (as of 3.5).

 

Summary:

The System.Web.Mail namespace was the original email messaging class in the .NET Framework.  It is a simple wrapper around CDOSYS.  The functionality availabe in SWM is actually a subset of that that is available in CDOSYS.  SWM can send email messages via SMTP through a local pickup directory or via port to an remote SMTP server.

Some Points Of Interest:

  • SWM is managed wrapper around CDOSYS - it only provides a subset of the functionality to send messages via SMTP, it does not do the same MIME parsing that CDOSYS can do.
  • SWM is replaced in the .NET Framework 2.0 by the System.Net.Mail namespace.
  • For whatever reason, a common mistake made when using SWM's SmtpMail class is to set the the SmtpServer property using the Insert(string) method off the SmtpServer property (which is a string).  The Insert method doesn't set the SmtpServer property so it remains empty - what does is it this changes the send method from port to local pickup directory. 
  • Debugging SWM issues is very systematic, there are only so many ways to send mail using SWM. 
  • Problems usually arise from changes to the configuraiton of the SMTP server - either added authentication requirements, server names, or open availability.  
  • Consider using System.Net.Mail or CDOSYS if you run into issues with System.Web.Mail since those are still supported and have broader capabilities.

Backgrounders:

System.Web.Mail Namespace
https://msdn.microsoft.com/en-us/library/System.Web.Mail(v=vs.110).aspx

MailMessage Class
https://msdn.microsoft.com/en-us/library/system.web.mail.mailmessage(v=vs.110).aspx

How to send e-mail programmatically by using System.Web.Mail in Visual C# 2005 or in Visual C# .NET
https://support.microsoft.com/en-us/kb/310273/en-us

Migrating from System.Web.Mail to System.Net.Mail
https://weblogs.asp.net/dfindley/Migrating-from-System.Web.Mail-to-System.Net.Mail

Also see:

About: SMTP Sending APIs
https://blogs.msdn.com/b/webdav_101/archive/2015/05/28/about-smtp-sending-apis.aspx

About: Messaging APIs
https://blogs.msdn.com/b/webdav_101/archive/2015/08/07/about-messaging-apis.aspx