C uses CDO to send mail
- 2021-07-18 08:47:51
- OfStack
This article illustrates how C # uses CDO to send mail. Share it for your reference. The specific analysis is as follows:
CDO is an COM component called Microsoft CDO For Exchange 2000 Library that we can use to connect to SMTP Server and send mail using username/password authentication.
/**
* C# Programmers Pocket Consultant
* Author: Gregory S. MacBeth
* Email: gmacbeth@comporium.net
* Create Date: June 27, 2003
* Last Modified Date:
* Version: 1
*/
using System;
using CDO;
using ADODB;
namespace Client.Chapter_19___Office_Integration
{
public class UsingCDOEx
{
static void Main(string[] args)
{
Message MyMessage = new MessageClass();
Configuration MyConfig = MyMessage.Configuration;
Fields MyFields = MyConfig.Fields;
MyFields[@"http://schemas.microsoft.com/cdo/configuration/sendusing"].Value = 2;
MyFields[@"http://schemas.microsoft.com/cdo/configuration/smtpserverport"].Value = 25;
MyFields[@"http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value = "smarthost";
MyFields.Update();
MyMessage.Configuration = MyConfig;
MyMessage.TextBody = "This is a test message";
MyMessage.Subject = "Testing";
MyMessage.From = "gregmcb@microsoft.com";
MyMessage.To = "pmacbeth@comporium.com";
MyMessage.Send();
}
}
}
I hope this article is helpful to everyone's C # programming.