Hi there,

I'm implementing a small e-mail sending method in the program I am currently writing and heard that CDO was a good way of doing it. I have no experience with it in the past, and the only tutorials I have come across are aimed at web-based apps using ASP. Does anyone know of anyone C# tutorials, or could maybe give me a push in the right direction.

Cheers in advance.

Dani AI

Generated

Short follow-up based on the thread: pointed you toward the built-in mail API and confirmed it solved the immediate need. For anyone reading this later, here are practical, up-to-date notes and a small alternative to consider.

Checklist for reliable sending

  • Verify SMTP settings: host, port (25 / 587 for STARTTLS / 465 for implicit SSL), and whether the server expects STARTTLS or SSL.
  • Provide credentials when required; many providers now require an app password or OAuth2 (Gmail stopped allowing plain "less secure" sign-ins).
  • Check firewall and ISP blocking of outbound SMTP ports. Use a quick telnet/PowerShell test to confirm connectivity.
  • Watch TLS/certificate errors — the runtime will throw an authentication/secure channel exception if TLS setup is wrong.

A modern alternative
SmtpClient/MailMessage (built into older .NET Framework) is fine for simple desktop tools and quick scripts, but Microsoft now recommends newer libraries for robust production use. For new projects consider MailKit, which supports modern authentication and async patterns (MailKit on GitHub). Example (MailKit usage):

using MimeKit;
using MailKit.Net.Smtp;
using MailKit.Security;

var msg = new MimeMessage();
// set From, To, Subject, Body...
using var client = new SmtpClient();
client.Connect("smtp.example.com", 587, SecureSocketOptions.StartTls);
client.Authenticate("user", "password");
client.Send(msg);
client.Disconnect(true);

Troubleshooting tips

  • Inspect the exception and its InnerException for network vs auth vs TLS causes.
  • Enable SMTP/server-side logs where possible.
  • For long-running services, prefer async send and ensure the client is disposed (or use MailKit which is async-friendly).
    For the historical built-in API, see the official docs for platform specifics and migration guidance (SmtpClient docs).

Recommended Answers

All 2 Replies

You may use classes of System.Net.Mail namespace to send email.

You may use classes of System.Net.Mail namespace to send email.

I ended up using that, worked great cheers.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.