2

I need to write a client that can send email to any smtp server. For non-ssl and explicit ssl based servers/ports I'm using System.Net.Mail.SmtpClient in the standard way. However I also need to support implicit ssl.

I'm fully aware that Gmail supports explicit ssl on port 587 and thus System.Net.Mail.SmtpClient can be used for that port. However I need to test code for connecting with implicit ssl and I'm using Gmail port 465 as a "test bed" for the principle of doing implicit ssl. Other servers I might need to connect to might not support explicit ssl.

Anyway, after tonnes of research (most of which ended in people suggesting System.Net.Mail.SmtpClient and not understanding why it can't be used for this) I've come across two methods of sending smtp mail to this port.

CDO (Collaborative Data Objects) as per this post. GMail SMTP via C# .Net errors on all ports

System.Web.Mail as per this post. https://stackoverflow.com/a/1014876/2536690

I've successfully got CDO working, but I was wondering if that is the preferred method. I know that System.Web.Mail is deprecated, but CDO is often referred to as "Collaboration Data Objects (CDO) for Windows 2000" and that "Windows 2000" bit makes me think it's also deprecated.

So is one of these preferred over the other? Is there another way I've missed in my research?

Community
  • 1
  • 1
RosieC
  • 608
  • 2
  • 11
  • 23

0 Answers0