Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

ASP 发送电子邮件 使用 CDOSYS


CDOSYS 是 ASP 中内置的组件。此组件用于使用 ASP 发送电子邮件。


使用 CDOSYS 发送电子邮件

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

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

CDONTs 呢?

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

使用 CDOSYS 的示例

发送文本电子邮件

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "使用 CDO 发送电子邮件"
myMail.From = "[email protected]"
myMail.To = "[email protected]"
myMail.TextBody = "这是一条消息。"
myMail.Send
set myMail = nothing
%>

发送带有 Bcc 和 CC 字段的文本电子邮件

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "使用 CDO 发送电子邮件"
myMail.From = "[email protected]"
myMail.To = "[email protected]"
myMail.Bcc = "[email protected]"
myMail.Cc = "[email protected]"
myMail.TextBody = "这是一条消息。"
myMail.Send
set myMail = nothing
%>

发送 HTML 电子邮件

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "使用 CDO 发送电子邮件"
myMail.From = "[email protected]"
myMail.To = "[email protected]"
myMail.HTMLBody = "<h1>这是一条消息。</h1>"
myMail.Send
set myMail = nothing
%>

发送从网站发送网页的 HTML 电子邮件

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "使用 CDO 发送电子邮件"
myMail.From = "[email protected]"
myMail.To ="[email protected]"
myMail.CreateMHTMLBody "https://w3schools.org.cn/asp/"
myMail.Send
set myMail = nothing
%>


发送从您计算机上的文件发送网页的 HTML 电子邮件

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "使用 CDO 发送电子邮件"
myMail.From = "[email protected]"
myMail.To = "[email protected]"
myMail.CreateMHTMLBody "file://c:/mydocuments/test.htm"
myMail.Send
set myMail = nothing
%>

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

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "使用 CDO 发送电子邮件"
myMail.From = "[email protected]"
myMail.To = "[email protected]"
myMail.TextBody = "这是一条消息。"
myMail.AddAttachment "c:\mydocuments\test.txt"
myMail.Send
set myMail = nothing
%>

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

<%
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "使用 CDO 发送电子邮件"
myMail.From = "[email protected]"
myMail.To = "[email protected]"
myMail.TextBody = "这是一条消息。"
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'远程 SMTP 服务器的名称或 IP
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.server.com"
'服务器端口
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
myMail.Configuration.Fields.Update
myMail.Send
set myMail = nothing
%>

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.