当前位置: 移动技术网 > IT编程>开发语言>c# > C#使用CDO发送邮件的方法

C#使用CDO发送邮件的方法

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了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#程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网