ASP 使用 CDOSYS 發(fā)送電子郵件
asp 使用 cdosys 發(fā)送電子郵件
cdosys 是 asp 中的內(nèi)建組件。此組件用于通過 asp 發(fā)送電子郵件。
使用 cdosys 發(fā)送電子郵件
cdo (collaboration data objects) 是一項(xiàng)微軟的技術(shù),設(shè)計(jì)目的是用來簡化通訊應(yīng)用程序的創(chuàng)建。
cdosys 是 asp 中的內(nèi)建組件。我們將向您演示如何通過 asp 使用該組件來發(fā)送電子郵件。
cdonts 怎么樣?
微軟已經(jīng)在 windows 2000、windows xp 和 windows 2003 中淘汰了 cdonts。如果您已經(jīng)在您的 asp 應(yīng)用程序中使用 cdonts,那么您需要更新代碼,并使用新的 cdo 技術(shù)。
使用 cdosys 的實(shí)例
發(fā)送文本電子郵件:
<%
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.textbody="this is a message."
mymail.send
set mymail=nothing
%>
發(fā)送帶有 bcc 和 cc 字段的文本電子郵件:
<%
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
%>
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
%>
發(fā)送 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
%>
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
%>
發(fā)送一封內(nèi)容為某個網(wǎng)站的某個網(wǎng)頁的 html 電子郵件:
<%
set mymail=createobject("cdo.message")
mymail.subject="sending email with cdo"
mymail.from="mymail@mydomain.com"
mymail.to="someone@somedomain.com"
mymail.createmhtmlbody "http:///asp/"
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.createmhtmlbody "http:///asp/"
mymail.send
set mymail=nothing
%>
發(fā)送一封內(nèi)容為您的計(jì)算機(jī)中某個文件的某個網(wǎng)頁的 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.createmhtmlbody "file://c:/mydocuments/test.htm"
mymail.send
set mymail=nothing
%>
發(fā)送一封帶有附件的文本電子郵件:
<%
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:mydocumentstest.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.addattachment "c:mydocumentstest.txt"
mymail.send
set mymail=nothing
%>
使用遠(yuǎn)程服務(wù)器發(fā)送一封文本電子郵件:
<%
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
%>
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
%>