欢迎光临
我们一直在努力

使用CDO通过外部邮件服务器发邮件 (免安装其他邮件组件)

建站超值云服务器,限时71元/月

使用cdo通过外部邮件服务器发邮件 (免安装其他邮件组件)
john peterson [ hooke 编译 ]

  win2k下的cdo或cdonts被默认配置成只能通过本地的microsoft smtp服务来发送邮件,如果要用外部的邮件服务器,一般要安装第三方组件。以下代码教你如何利用cdo通过外部邮件服务器发送邮件。(译者win2000下测试通过。)

<%
const cdosendusingmethod="http://schemas.microsoft.com/cdo/configuration/sendusing"
const cdosendusingport=2
const cdosmtpserver="http://schemas.microsoft.com/cdo/configuration/smtpserver"
const cdosmtpserverport="http://schemas.microsoft.com/cdo/configuration/smtpserverport"
const cdosmtpconnectiontimeout="http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
const cdosmtpauthenticate="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
const cdobasic=1
const cdosendusername="http://schemas.microsoft.com/cdo/configuration/sendusername"
const cdosendpassword="http://schemas.microsoft.com/cdo/configuration/sendpassword"

dim objconfig   as cdo.configuration
dim objmessage as cdo.message
dim fields      as adodb.fields

set objconfig = server.createobject("cdo.configuration")
set fields = objconfig.fields

with fields
.item(cdosendusingmethod)       = cdosendusingport
.item(cdosmtpserver)            = "sony.com"  改成可用的外部邮件服务器域名
.item(cdosmtpserverport)        = 25
.item(cdosmtpconnectiontimeout) = 10
.item(cdosmtpauthenticate)      = cdobasic
.item(cdosendusername)          = "hooke"   以上服务器的用户名
.item(cdosendpassword)          = "mypassword"   密码
.update
end with

set objmessage = server.createobject("cdo.message")
set objmessage.configuration = objconfig

with objmessage
.to       = "f4@meteorgardon.com"  改成接收者的邮件地址
.from     = "hooke@sony.com"  改成发送人的邮件地址
.subject  = "smtp relay test"  标题
.textbody = "smtp relay test sent @ " & now() 正文
.send
end with

set fields = nothing
set objmessage = nothing
set objconfig = nothing
%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 使用CDO通过外部邮件服务器发邮件 (免安装其他邮件组件)
分享到: 更多 (0)

相关推荐

  • 暂无文章