社内邮件自动发送

namespace CdoSys
{
 using System;
 class Class1
 {
  static void Main(string[] args)
  {
   try
   {   
    CDO.Message oMsg = new CDO.Message();
    CDO.IConfiguration iConfg;

    iConfg = oMsg.Configuration;

    ADODB.Fields oFields;
    oFields = iConfg.Fields;      

    // Set configuration.
    ADODB.Field oField = oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"];
                       
    //TODO: To send by using the smart host, uncomment the following lines:
    //oField.Value = CDO.CdoSendUsing.cdoSendUsingPort;
    //oField = oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"];
    //oField.Value = "smarthost";

    // TODO: To send by using local SMTP service.
    //oField = oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"];
    //oField.Value = 1; 

    oFields.Update();

    // Set common properties from message.

    //TODO: To send text body, uncomment the following line:
    //oMsg.TextBody = "Hello, how are you doing?";
   

    //TODO: To send HTML body, uncomment the following lines:
    //String sHtml;
    //sHtml = "<HTML>/n" +
    // "<HEAD>/n" +
    // "<TITLE>Sample GIF</TITLE>/n" +
    // "</HEAD>/n" +
    // "<BODY><P>/n" +
    // "<h1><Font Color=Green>Inline graphics</Font></h1>/n" +
    // "</BODY>/n" +
    // "</HTML>";
    //oMsg.HTMLBody = sHtml;

    //TOTO: To send WEb page in an e-mail, uncomment the following lines and make changes in TODO section.
    //TODO: Replace with your preferred Web page
    //oMsg.CreateMHTMLBody("http://www.microsoft.com",
    // CDO.CdoMHTMLFlags.cdoSuppressNone,
    // "", "");
    oMsg.Subject = "Test SMTP"; 

    //TODO: Change the To and From address to reflect your information.                      
    oMsg.From = "someone@example.com";
    oMsg.To = "someone@example.com";
    //ADD attachment.
    //TODO: Change the path to the file that you want to attach.
    oMsg.AddAttachment("C://Hello.txt", "", "");
    oMsg.AddAttachment("C://Test.doc", "", "");
                                    oMsg.Send();
   }
   catch (Exception e)
   {
    Console.WriteLine("{0} Exception caught.", e);
   }
   return;
  }
 }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值