使用CDO发送邮件

引用CDO组件,SYSTEM32下的CDOSYS。DLL,增加一个包装器

using CDO;

 //本例使用CDO来实现发送邮件,可带验证,此示例在活动目录内向外网发送邮件成功  profession2k office2k office2k3下通过 VS2,2,VS2k3,要引用CDOSYS
   Configuration conf=new Configuration();
   //以下部分设置参数(服务器,端号,用户名,密码,发送邮件帐号,回复邮箱帐号)
   conf.Fields[CdoConfiguration.cdoSendUsingMethod].Value=CdoSendUsing.cdoSendUsingPort;
   conf.Fields[CdoConfiguration.cdoSMTPServer].Value="smtp.21cn.com";
   conf.Fields[CdoConfiguration.cdoSMTPServerPort].Value=25;
   conf.Fields[CdoConfiguration.cdoSMTPAccountName].Value="[email protected]";
   conf.Fields[CdoConfiguration.cdoSendUserReplyEmailAddress].Value="/"greystar/" <[email protected]>";
   conf.Fields[CdoConfiguration.cdoSendEmailAddress].Value="/"greystar/" <[email protected]>";
   conf.Fields[CdoConfiguration.cdoSMTPAuthenticate].Value=CdoProtocolsAuthentication.cdoBasic;
   conf.Fields[CdoConfiguration.cdoSendUserName].Value="[email protected]";
   conf.Fields[CdoConfiguration.cdoSendPassword].Value="XXXXXXX";

   conf.Fields.Update();
   MessageClass msg=new MessageClass();

   msg.Configuration=conf;
  
   msg.To="[email protected]";
   msg.Subject= "注册确认通知";
   msg.HTMLBody="注册信息"
     msg.From="[email protected]";

   msg.Send();  

 

你可能感兴趣的:(服务器,活动,Office,System,dll)