ASP 发送电子邮件光盘系统


CDOSYS 是 ASP 中的内置组件。该组件用于通过 ASP 发送电子邮件。


使用 CDOSYS 发送电子邮件

CDO(协作数据对象)是一项 Microsoft 技术,旨在简化消息应用程序的创建。

CDOSYS 是 ASP 中的内置组件。我们将向您展示如何使用该组件通过 ASP 发送电子邮件。

CDONT 怎么样?

Microsoft 已停止在 Windows 2000、Windows XP 和 Windows 2003 上使用 CDONT。如果您已在 ASP 应用程序中使用 CDONT,则应更新代码并使用新的 CDO 技术。

使用 CDOSYS 的示例

发送文本电子邮件:

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "mymail@mydomain.com"
myMail.To = "someone@somedomain.com"
myMail.TextBody = "This is a message."
myMail.Send
set myMail = nothing
%>

发送带有密件抄送和抄送字段的文本电子邮件:

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "mymail@mydomain.com"
myMail.To = "someone@somedomain.com"
myMail.Bcc = "someoneelse@somedomain.com"
myMail.Cc = "someoneelse2@somedomain.com"
myMail.TextBody = "This is a message."
myMail.Send
set myMail = nothing
%>

发送 HTML 电子邮件:

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "mymail@mydomain.com"
myMail.To = "someone@somedomain.com"
myMail.HTMLBody = "<h1>This is a message.</h1>"
myMail.Send
set myMail = nothing
%>

发送一封 HTML 电子邮件,该电子邮件从网站发送网页:

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "mymail@mydomain.com"
myMail.To ="someone@somedomain.com"
myMail.CreateMHTMLBody "https://www.91xjr.com/asp/"
myMail.Send
set myMail = nothing
%>


发送一封 HTML 电子邮件,该电子邮件从您计算机上的文件发送网页:

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "mymail@mydomain.com"
myMail.To = "someone@somedomain.com"
myMail.CreateMHTMLBody "file://c:/mydocuments/test.htm"
myMail.Send
set myMail = nothing
%>

发送带有附件的文本电子邮件:

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "mymail@mydomain.com"
myMail.To = "someone@somedomain.com"
myMail.TextBody = "This is a message."
myMail.AddAttachment "c:\mydocuments\test.txt"
myMail.Send
set myMail = nothing
%>

使用远程服务器发送文本电子邮件:

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "Sending email with CDO"
myMail.From = "mymail@mydomain.com"
myMail.To = "someone@somedomain.com"
myMail.TextBody = "This is a message."
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.server.com"
'Server port
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
myMail.Configuration.Fields.Update
myMail.Send
set myMail = nothing
%>