當前位置: 首頁IT技術(shù) → ASP中使用CDO.Message+SMTP發(fā)送郵件的函數(shù)代碼分享

ASP中使用CDO.Message+SMTP發(fā)送郵件的函數(shù)代碼分享

更多
 下面提供給大家分享的是關(guān)于在ASP中使用CDO.Message+SMTP發(fā)送郵件的函數(shù)代碼,希望能對大家有所幫助。
<!--發(fā)送代碼-->
<%
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服務(wù)器" '改成可用的外部郵件服務(wù)器域名
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "用戶名" '以上服務(wù)器的用戶名
.Item(cdoSendPassword) = "密碼" '密碼
.Update
End With

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

With objMessage
.To = Trim(Request.Form("m_user")) '改成接收者的郵件地址
.From = "發(fā)件人的地址(要和上面的郵件系統(tǒng)相同)" '改成發(fā)送人的郵件地址
.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
%>
<!--發(fā)送代碼-->
熱門評論
最新評論
發(fā)表評論 查看所有評論(1)
昵稱:
表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
字數(shù): 0/500 (您的評論需要經(jīng)過審核才能顯示)