• Moges
  • 2013-07-27

CDONTS组件是做什么用的?

CDONTS组件
在ASP中发送Email时往往需要一个COM组件支持,如果你没有第三方的Email组件,你可以使用IIS本身提供CDONTS EMail组件。这个组件使用时需要安装和启动SMTP服务。这个组件的名称为CDONTS.DLL,使用前需要使用RegSvr32注册这个组件。

  CDONTS组件提供了一系列对象,包括AddressEntry、Attachment、Attachments、Folder、Message、Messages、NewMail、Recipient、Recipients、Session,我们经常使用的是NewMail对象。下面是NewMail对象提供的方法和属性:

名称
功能 格式
Attach 添加附件 Sub AttachFile(Source, [FileName], [EncodingMethod])
AttachURL 以格式添加附加和数据 Sub AttachURL(Source,ContentLocation, [ContentBase], [EncodingMethod])
BCC 以“,”分隔的接收者列表(暗送) 字符串类型属性
Body TextHTML 字符串类型属性
bodyformat 邮件正文格式 0:HTMl1:Text
CC 以“,”分隔的接收者列表(抄送) 字符串类型属性
ContentBase 带有附件的邮件中正文采用的基地址 字符串类型属性
ContentLocation 带有附件的邮件中正文采用的 字符串类型属性
From 邮件发送方地址 字符串类型属性
Importance 邮件级别 0: 1 2:
Send 发送邮件 Sub Send([From], [To], [Subject], [Body], [Importance]) 各个参数可以参考上下文属性
SetLocaleIDs 设置新消息的代码页标识 Sub SetLocaleIDs(CodePageID As Long)
Subject 邮件主题 字符串类型属性
To 以“,”分隔的接收者地址列表 字符串类型属性
Value 任意的邮件头的值 字符串类型属性
Version 当前集合数据对象库()的版本号 只读字符串类型属性

在使用有关对象的方法时,方括号参数可以省略。

下面是采用ASP使用的例子:

Dim MailObject
Set MailObject = Server.CreateObject("CDONTS.NewMail")
MailObject.Send "发送方邮件地址","接收方邮件地址","主题","邮件正文"

发送附件时可以这样:
Dim MailObject

Set MailObject = Server.CreateObject("CDONTS.NewMail")
att_fileName="附件文件名完整路径"
f_name="文件名"
MailObject.From="在这填写发件人地址"
MailObject.To="在这填写接收人地址"
MailObject.Subject="填写主题"
MailObject.Body="填写正文"
MailObject.AttachFile att_file,f_name
MailObject.Send

注意:发送邮件时需要IUSR_用户对 x:\Inetpub\mailroot 目录有读写权限。 

 

CDONTS组件:你不必专门下载,微软已经提供了这个组件,只要安装了NT的SMTP就会有的。
下面我们利用这个组件来做一个客户调查反馈表单(Webmail)。表单主要代码如下:

您的姓名: 
电子邮件: 
邮件主题: 
您的意见和建议:

Professional mold, automation parts manufacturing industry management software
Small and Medium-sized Enterprise ERP, MES, and MRP Solutions
Trade Inventory SaaS Management System, Linux Email Server Solution

Tel: 18625220688

Solutions

Mold Manufacturing Digitalization
Focused on mold shop production management, significantly shortening delivery cycles
ERP Systems for the Sheet Metal Industry
End-to-end management of laser cutting, bending, and welding
Custom Automation Equipment Management
Integrated quotes, production progress, and cost accounting
Tooling & Fixture Management Systems
Fully digital control of the inspection fixture production process

Resource Downloads

MES Whitepaper

In-depth Guide to Mold Manufacturing Execution Systems

Product Documentation

Moges PMS System Feature Guide

FAQ

Answers to all your questions

Contact Us

Now
Talk to Us

14 years of industry experience, focused on the digital transformation of mold, sheet metal, and custom automation equipment manufacturing

186 2522 0688

Headquartered in Kunshan, with on-site service within a 2-hour radius

Contact
Product & Service Inquiry

Free Online Consultation on Products & Solutions

Get a Quote

FAQ

Q:CDONTS组件需要什么前提条件才能使用?
A:需在Windows服务器上安装并启动IIS SMTP服务,并用RegSvr32注册CDONTS.DLL文件。

Q:CDONTS中最常用的对象是什么?
A:NewMail对象,用于构建和发送邮件,支持To、From、Subject、Body、AttachFile等关键属性和方法。

Q:CDONTS支持HTML格式邮件吗?
A:支持,通过设置bodyformat=0(HTML)或1(纯文本)控制正文格式。

Q:如何实现邮件抄送和暗送?
A:分别使用NewMail对象的CC(字符串逗号分隔邮箱)和BCC属性即可。

Latest News

Online Subscription