当前位置:首页文章首页 IT学院 IT技术

ASP中使用CDO.Message+SMTP发送邮件的函数代码分享

作者:  来源:  发布时间:2011-6-15 11:51:02  点击:
 下面提供给大家分享的是关于在ASP中使用CDO.Message+SMTP发送邮件的函数代码,希望能对大家有所帮助。
<!--发送代码-->
<%
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) = "SMTP服务器" '改成可用的外部邮件服务器域名
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "用户名" '以上服务器的用户名
.Item(cdoSendPassword) = "密码" '密码
.Update
End With

Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig

With objMessage
.To = Trim(Request.Form("m_user")) '改成接收者的邮件地址
.From = "发件人的地址(要和上面的邮件系统相同)" '改成发送人的邮件地址
.Subject = Trim(Request.Form("m_zhuzi")) '标题
.TextBody = Trim(Request.Form("m_neirong")) '正文
'.AddAttachment "C:\Scripts\Output.txt"'邮件附件
.Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
%>
<!--发送代码-->

相关软件

相关文章

文章评论

软件按字母排列: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z