About: SMTP Sending APIs
Summary:
Microsoft has several APIs which send email by SMTP. These 'SMTP Senders' are meant to send email to SMTP servers and do not have access to a mailboxes or public folders. Mail submitted by SMTP will not be saved into the Sent Items of the sender's mailbox. The beauty of these APIs is that they can send a lot of email very fast and do not need to go against Exchange or Outlook in order to work - they just need an SMTP server which will either pickup the email from its pickup folder or accept relay from the application using the API.
These APIs are used for sending mail via the SMTP protocol. These APIs are not Exchange or Outlook specific. They are shipped as either part of the Windows OS or with the .NET Framework.
The APIs:
- About: System.Net.Mail (SNM)
https://blogs.msdn.com/b/webdav_101/archive/2015/05/18/about-system-net-mail-snm.aspx
System.Net.Mail is fully written in .NET code and can send by SMTP pickup folder and by SMTP port. It has many of the capabilities of CDOSYS.
- About: System.Web.Mail (SWM)
https://blogs.msdn.com/b/webdav_101/archive/2015/05/18/about-system-web-mail.aspx
The System.Web.Mail namespace was the original email messaging class in the .NET Framework. SWM is replaced in the .NET Framework 2.0 by the System.Net.Mail namespace. It is a partial wrapper for CDOSYS, however it had very limited functionality.
- CDO for Windows 2000 (CDOSYS)
https://blogs.msdn.com/b/webdav_101/archive/2015/05/18/about-cdo-for-windows-2000-_2800_cdosys_2900_.aspx
CDOSYS is a COM API which has been around since Windows 2000 and is still fully supported today. Its part of the Windows OS. This API can send to pickup folders, send by SMTP port, has good body manipulation abilities and can be used to also parse MIME.
- CDO for Windows NT (CDONTS)
https://blogs.msdn.com/b/webdav_101/archive/2008/09/09/about-cdo-for-windows-nt-cdonts.aspx
CDONTS is a very old API which sent email by SMTP pickup folder and was last supported with Windows 2000. CDOSYS was the replacement for it.
Troubleshooting:
If you are running into issues with sending by SMTP port and don't believe its your code then code then be sure to check to be sure the issue is not with the SMTP server or permissions:
XFOR: Telnet to Port 25 to Test SMTP Communication
https://support.microsoft.com/en-us/kb/153119
How to Use Telnet to Test SMTP Communication
https://technet.microsoft.com/en-us/library/aa995718(v=exchg.65).aspx
Some Points Of Interest:
- If you get an error while sending to a pickup folder which seems to be permissions based then look at using ProcMon to see if there is an access denied for the application writing to the pickup folder.
- If you get an error when sending all but very small email then there could be a permission error with the API writing to a temp folder. These APIs usually write out to a temporary folder with messages above a certain size - that size may vary. Use Procmon to see if there is an access denied in any temp folder and correct permissions so the application can write to it. Note that the temp folder may vary depending upon the type of application - windows form, windows service, web service, etc.
- All code which sends by SMTP port needs to account for issues with the server being tied up - yes, an SMTP server may get overloaded or otherwise backed-up.
- Sending by the pickup folder of locally installed SMTP server is usually the most efficient way to send email. It also does not tie up the thread sending the email. It the best way to send a large amount of email in almost every case.
Also see:
About: Messaging APIs
https://blogs.msdn.com/b/webdav_101/archive/2015/08/07/about-messaging-apis.aspx