◎◎中国dnn建设自己的家园◎◎
●●欢迎来ME我●●
组件CDONTS.NewMail 描述

NewMail 对象(CDONTS 库)
NewMail 对象提供只用很少的几行代码即可发送邮件的功能。

速查
声明的类型库: CDONTS.DLL  
首次启用: CDO for NTS Library 版本 1.2  
父对象:  (无)
子对象:  (无)
默认属性: Value  


属性

名  首次启用版本 类型  访问

Bcc  1.2  字符串  只写  
Body  1.2  IStream 对象或字符串  只写  
BodyFormat  1.2  长整型  只写  
Cc  1.2  字符串  只写  
ContentBase  1.2  字符串  只写  
    
ContentLocation  1.2  字符串  只写  
From  1.2  字符串  只写  
Importance  1.2  长整型  只写  
MailFormat  1.2  长整型  只写  
Subject  1.2  字符串  只写  
To  1.2  字符串  只写  
Value  1.2  字符串  只写  
Version  1.2  字符串  只读  


方法

名  首次启用版本 参数  

AttachFile  1.2  Source 作为 对象 或 字符串,
(可选项)FileName 作为 字符串,
(可选项)EncodingMethod 作为 长整型  
AttachURL  1.2  Source 作为 对象 或 字符串,
ContentLocation 作为 字符串,
(可选项) ContentBase 作为 字符串,
(可选项)EncodingMethod 作为 长整型  
   
Send  1.2  (可选项)From 作为 字符串,
(可选项)To 作为 字符串,
(可选项)Subject 作为 字符串,
(可选项)Body 作为 对象 或 字符串,
(可选项)Importance 作为 长整型  
SetLocaleIDs  1.2  CodePageID 作为 长整型  


注释
NewMail 对象不是建立在普通的 API 体系结构上。它被 Microsoft? Windows NT? Server 中运行的自动进程用于快速产生通告邮件。它不提供任何用户接口,在邮件的产生和发送过程中也不提供任何的交互。因此 NewMail 对象的属性没有被设计成为可以回读和检查。仅除 Version 外,其他属性只能被写入。

NewMail 对象是完备的并且不暴露任何 公共于所有的 CDO for NTS 库对象的属性。

一旦将附件和收件人添加到 NewMail 对象,就不能清除它们了,并且 NewMail 对象本身也不能被删除。当 Send 方法成功完成任务时,NewMail 对象将失效但并不从内存中清除。程序员应该将失效对象设置为 Nothing 以便将其从内存中清除或给它重新分配另一个 NewMail 对象。企图访问已发送的 NewMail 对象将导致返回 CdoE_INVALID_OBJECT。

NewMail 对象不在包含 CDO for NTS Library 对象的层次结构中。它不能访问其他任何对象,也不能从其他对象中访问。与 Session 对象一样,它被认为是最上层的对象并且直接由 Microsoft? Visual Basic? 程序创建。其 ProgID 是 CDONTS.NewMail。下面这段代码通过早期的绑定创建了一个 NewMail 对象:

  Dim objNewMail As CDONTS.NewMail
  Set objNewMail = CreateObject("CDONTS.NewMail")

NewMail 对象的主要优点在于它产生和传送邮件的简单性和易用性。用户不必登录到一个会话,也不必与文件夹和邮件集合打交道。只需创建 NewMail 对象,将其发送出去,然后将其设置为 Nothing 即可。用户可以在 Send 方法的参数中提供关键信息。在多数情况下,只需 3 行代码:

  Set objNewMail = CreateObject("CDONTS.NewMail")
  objNewMail.Send("me@company.com", "you@company.com", "Hello", _
                  "I sent this in 3 statements!", 0) '' low importance
  Set objNewMail = Nothing '' canNOT reuse it for another message

因为可以在 AttachFile 方法的参数中传递信息,所以要包含一个附件,只需在您的代码中加入一条语句即可:

  Set objNewMail = CreateObject("CDONTS.NewMail")
  objNewMail.AttachFile("\\server\schedule\sched.xls", "SCHED.XLS")
  objNewMail.Send("Automated Schedule Generator", "you@company.com", _
                  "Schedule", "Here''s the latest master schedule", 0)
  Set objNewMail = Nothing


Windows xp, Windows 2003 默认没有附带CDONTS.DLL,必须手动安装,你可以从Windows 2000的system32中得到该文件,
 如果没有,也可以在这里下载(下载CDOv1.2 CDONTS.DLL 394KB),安装方法:
 Step1: 将该文件拷贝至 %SystemRoot%\System32 下;
 Step2: 开始 -> 运行 -> Regsvr32 cdonts.dll;
 Step3: 确认

发贴心情
组件CDONTS.NewMail 问题!

sub sendmail(fromwho,towho,ccwho,subject,mailbody,mailformat,bodyformat)
 dim mymail
 set mymail=server.createobject("CDONTS.NewMail")            188行
  mymail.mailformat=mailformat
  mymail.bodyformat=bodyformat
  mymail.from=fromwho
  mymail.to=towho
  mymail.cc=ccwho
  mymail.subject=subject
  mymail.body=mailbody
  mymail.send
 set mymail=nothing
end sub

 

  • 错误类型:
    Server 对象, ASP 0177 (0x800401F3)
    无效的类别字符串
    /_lib/_lib.asp, 第 188 行

     

  • 浏览器类型:
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)

     

  • 网页:
    POST 172 ??? /purchase/dgservices.asp

     

  • POST Data:
    txtorderman=iuyiuy&txtrecadd=%C0%D5%BF%CB%CB%BE%BD%B4%B6%B9%B8%AF%B8%D0&txtreczip=987897987&txtrecPhone=987987897&txtrecEmail=iusdy@163.com&imageField2.x=41&imageField2.y=7
  • CDONTS.NewMail 组件使用说明

    Set MailObject = Server.CreateObject("CDONTS.NewMail")
      MailObject.From = "发信邮箱"
      MailObject.To = "收信邮箱"
      MailObject.Cc = "抄送邮箱"
      MailObject.Bcc = "密送邮箱"
      MailObject.Subject = "邮件主题"
      MailObject.Body = "邮件内容"
      MailObject.MailFormat = 0 '邮件的格式,0是MIME格式,1是文本消息
      MailObject.BodyFormat = 0 '邮件的正文的格式,0表示HTML格式,1表示普通文本
      MailObject.Importance = 1 '邮件的重要性,0是表示低重要性,1表示正常,2表示高重要
      MailObject.AttachFile "附件绝对路径","附件名称"
      MailObject.Send
      Set MailObject = Nothing

    发信例子::
    Click here to copy the Code to your clipboard (Only for IE Users)


    'Declare Variables
    Dim CDONTSObj, MessageBody

    'Create the CDONTS object
    Set CDONTSObj = Server.CreateObject("CDONTS.NewMail")

    'To Address
    CDONTSObj.To = "info@scriptmate.com"

    'From Address
    CDONTSObj.From = "you@yoursite.com"

    'CC Email Addresses seperated by a comma
    CDONTSObj.cc = "support@scriptmate.com,amit@millioncolors.com"

    'Your Email Message
    MessageBody = "Sending a email using ASP was never so easy ! "

    'Subject of the Email Message
    CDONTSObj.Subject = "Send a Email"

    'Assigning the value of your message to the Object
    CDONTSObj.Body = MessageBody

    'Send the email
    CDONTSObj.Send

    'Set the CDONTS object to nothing
    Set CDONTSObj = nothing


     

    posted on 2006-04-16 09:41  狐寒  阅读(1190)  评论(0编辑  收藏  举报