Exchange Server学习---发送邮件

Introduction to Collaboration Data Objects for Microsoft Exchange 2000

 

  介绍了CDO的一些知识,并介绍了如何使用CDO协同Exchange Server进行工作。
     
   
  文章中提供了几个使用CDO进行工作的示例,不过全部都是asp时代的代码,看着费劲,还是转换成c#巴:)

   1 发送邮件
'vb
'Create variable
Dim objAddressee

'Point it to a CDO addressee object
Set objAddressee = CreateObject("CDO.Addressee")
'Set the address to send to
objAddressee.emailaddress = "[email protected]"
'Declare the message variable, Msg
Dim Msg

'Since this is VBScript, you must use the CreateObject method.
Set Msg = CreateObject("CDO.Message")
With Msg
   .To   = "[email protected]"
   .From = "[email protected]"
   .Subject  = "Lunch meeting"
   .TextBody = "I have attached the suggested menu."
   .AddAttachment "file://c:/menu.doc"
   .Send
End With


//c#
//例子中的Set objAddressee = CreateObject("CDO.Addressee")在以后的代码中并没有出现,于是x掉
CDO.Message msg=new CDO.MessageClass();

   msg.To="some@some";
   msg.From="some@some";
   msg.Subject="this is11111 subject";
   msg.TextBody="this is test body";
  
   msg.AddAttachment("c:\\1.txt","username","password");//好像用户名&密码填错了没有关系

   msg.Send();

你可能感兴趣的:(Exchange)