手机
当前位置:查字典教程网 >编程开发 >C#教程 >C#使用CDO发送邮件的方法
C#使用CDO发送邮件的方法
摘要:本文实例讲述了C#使用CDO发送邮件的方法。分享给大家供大家参考。具体分析如下:CDO是一个名为MicrosoftCDOForExchang...

本文实例讲述了C#使用CDO发送邮件的方法。分享给大家供大家参考。具体分析如下:

CDO是一个名为Microsoft CDO For Exchange 2000 Library的COM组件,我们可以用它来连接SMTP Server,使用用户名/密码验证发送邮件。

/** * 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(); } } }

希望本文所述对大家的C#程序设计有所帮助。

【C#使用CDO发送邮件的方法】相关文章:

C# dynamic关键字的使用方法

C# 禁用鼠标中间键的方法

SQL语句删除和添加外键、主键的方法

用C#编写获取远程IP,MAC的方法

C#中Web.Config加密与解密的方法

C#操作config文件的具体方法

C#计算代码执行时间的方法

使用C#获取系统特殊文件夹路径的解决方法

C#注释的一些使用方法浅谈

C#中读写INI文件的方法例子

精品推荐
分类导航