How to send cdo email from C#

The Microsoft .NET framework includes two namespaces, namely System.Net and System.Net.Sockets, which provide a managed implementation of Internet protocols. These namespaces allow applications to send or receive data over the Internet.

Cdosys.dll library

In the previous C# program, we learned how to send an email with a text body using the SMTP (Simple Mail Transfer Protocol). However, in this scenario, we are sending an email without using the SMTP protocol through C# programming. Instead of SMTP, we will be utilizing CDOSYS (Collaboration Data Objects for Windows 2000 library) for this purpose. CDOSYS is also known as Cdosys.dll, which is a library that provides functionality for sending emails.

We will leverage the Cdosys.dll library to send emails from our C# program without using them to process the SMTP communication protocol. To build an effective email sending mechanism for emails, this library has been offered with the different options aside from the general email sending features and allows customizing the email contents in terms of format and presentation.

Create a new C# project and add a reference to Microsoft CDO For Windows 2000 Library . From the following picture you can understand how to add Microsoft CDO For Windows 2000 Library in your C# project.

csharp-cdo Full Source C#
using System; using System.Windows.Forms; using System.Net.Mail; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { CDO.Message oMsg = new CDO.Message(); CDO.IConfiguration iConfg; iConfg = oMsg.Configuration; ADODB.Fields oFields; oFields = iConfg.Fields; ADODB.Field oField = oFields[""]; oFields.Update(); oMsg.Subject = "Test CDO"; oMsg.From = "from_address"; oMsg.To = "to_address"; oMsg.TextBody = "CDO Mail test"; oMsg.Send(); MessageBox.Show("mail Send"); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } } }


Exploring the CDOSYS library and understanding its usage in C# programming, you can explore alternative methods for sending emails and utilize the specific features and capabilities it offers.