狠狠色丁香婷婷综合尤物/久久精品综合一区二区三区/中国有色金属学报/国产日韩欧美在线观看 - 国产一区二区三区四区五区tv

LOGO OA教程 ERP教程 模切知識交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

asp發(fā)送郵件(email)方法集合

admin
2011年4月8日 0:20 本文熱度 3476

首先是jmail.smtpmail的核心代碼:


Set jmail = Server.CreateObject("JMAIL.SMTPMail") '創(chuàng)建一個(gè)JMAIL對象
jmail.silent = true 'JMAIL不會拋出例外錯誤,返回的值為FALSE跟TRUE
jmail.logging = true '啟用使用日志
jmail.Charset = "GB2312" '郵件文字的代碼為簡體中文
jmail.ContentType = "text/html" '郵件的格式為HTML的
jmail.ServerAddress = "Server Address" '發(fā)送郵件的服務(wù)器
jmail.AddRecipient Email '郵件的收件人
jmail.SenderName = "SenderName" '郵件發(fā)送者的姓名
jmail.Sender = "Email Address" '郵件發(fā)送者的郵件地址
jmail.Priority = 1 '郵件的緊急程序,1 為最快,5 為最慢, 3 為默認(rèn)值
jmail.Subject = "Mail Subject" '郵件的標(biāo)題
jmail.Body = "Mail Body" '郵件的內(nèi)容
jmail.AddRecipientBCC Email '密件收件人的地址
jmail.AddRecipientCC Email '郵件抄送者的地址
jmail.Execute() '執(zhí)行郵件發(fā)送
jmail.Close '關(guān)閉郵件對象



--------------------------------------------------------------------------------
接下來是jmail.message的核心代碼:


Set jmail = Server.CreateObject("JMAIL.Message") '建立發(fā)送郵件的對象
jmail.silent = true '屏蔽例外錯誤,返回FALSE跟TRUE兩值
jmail.logging = true '啟用郵件日志
jmail.Charset = "GB2312" '郵件的文字編碼為國標(biāo)
jmail.ContentType = "text/html" '郵件的格式為HTML格式
jmail.AddRecipient Email '郵件收件人的地址
jmail.From = "Email From for Sender" '發(fā)件人的E-MAIL地址
jmail.MailServerUserName = "UserName of Email" '登錄郵件服務(wù)器所需的用戶名
jmail.MailServerPassword = "Password of Email" '登錄郵件服務(wù)器所需的密碼
jmail.Subject = "Mail Subject" '郵件的標(biāo)題
jmail.Body = "Mail Body" '郵件的內(nèi)容
jmail.Priority = 1 '郵件的緊急程序,1 為最快,5 為最慢, 3 為默認(rèn)值
jmail.Send("Server Address") '執(zhí)行郵件發(fā)送(通過郵件服務(wù)器地址)
jmail.Close() '關(guān)閉對象


--------------------------------------------------------------------------------
再接著就是CDONTS的發(fā)郵件的簡單代碼:


Set cdomail = Server.CreateObject("CDONTS.NewMail") '建立郵件對象
cdomail.Subject = "Mail Subject" '郵件標(biāo)題
cdomail.From = "Sender's Mail" '發(fā)件人的地址
cdomail.To = "Email will from" '收件人的地址
cdomail.Body = "Mail Body" '郵件的內(nèi)容
cdomail.Send '執(zhí)行發(fā)送


這種方法發(fā)送郵件是最簡單的,同時(shí)也帶來一定的問題,就是很少有服務(wù)器會開這項(xiàng)服務(wù)!


--------------------------------------------------------------------------------
以上三種列出的是兩個(gè)組件的三種發(fā)送方法,其中第二種是有身份驗(yàn)證的,也就是說有要求驗(yàn)證的郵箱如果不用這種方法發(fā)送的話,是無法收到信件的。如接收郵箱為 163、yahoo等,沒有用第二種方法發(fā)的話,是收不到郵件的。


接下來是一個(gè)簡單的例子,由于頁面的關(guān)系,我在此只做一個(gè)例子,另外兩種可以用同樣的方法來處理的。


我們寫程序,一般情況下都是說要代碼模塊化,這樣方便維護(hù),同時(shí)也方便移植。因此,我在這里將這個(gè)發(fā)郵件的寫成一個(gè)子程,在調(diào)用的時(shí)候可以直接調(diào)用(當(dāng)然,如果你高興寫成函數(shù)的話也是可以的,這個(gè)主要是看個(gè)人興趣)


 


這里引用第一種


Sub SendAction(subject, mailaddress, email, sender, content, fromer) '在這里,我把標(biāo)題,發(fā)件服務(wù)器的地址,收件人,郵件內(nèi)容及發(fā)件人都列到這個(gè)項(xiàng)目中
'方便以后使用的時(shí)候直接修改發(fā)送表單,而不用去修改核心代碼
Set jmail = Server.CreateObject("JMAIL.SMTPMail") '創(chuàng)建一個(gè)JMAIL對象
jmail.silent = true 'JMAIL不會拋出例外錯誤,返回的值為FALSE跟TRUE
jmail.logging = true '啟用使用日志
jmail.Charset = "GB2312" '郵件文字的代碼為簡體中文
jmail.ContentType = "text/html" '郵件的格式為HTML的
jmail.ServerAddress = mailaddress '發(fā)送郵件的服務(wù)器
jmail.AddRecipient Email '郵件的收件人
jmail.SenderName = sender '郵件發(fā)送者的姓名
jmail.Sender = fromer '郵件發(fā)送者的郵件地址
jmail.Priority = 1 '郵件的緊急程序,1 為最快,5 為最慢, 3 為默認(rèn)值
jmail.Subject = subject '郵件的標(biāo)題
jmail.Body = content '郵件的內(nèi)容
'由于沒有用到密抄跟抄送,這里屏蔽掉這兩句,如果您有需要的話,可以在這里恢復(fù)
'jmail.AddRecipientBCC Email '密件收件人的地址
'jmail.AddRecipientCC Email '郵件抄送者的地址
jmail.Execute() '執(zhí)行郵件發(fā)送
jmail.Close '關(guān)閉郵件對象
End Sub


以上我已經(jīng)將代碼做成一個(gè)塊,下面是對該塊的具體引用法!



如我收到的值分別如下:


郵件標(biāo)題(subject):JMAIL發(fā)信
郵件內(nèi)容(content):這是一封測試郵件
發(fā)信人的地址(fromer):runbing@eyou.com
發(fā)信者的姓名(sender):帥青蛙
收信人的地址(email):runbing@eyou.com
郵件服務(wù)器的地址(mailaddress):mail.ubbcn.com


則我調(diào)用發(fā)信塊的時(shí)候(SendAction subject,mailaddress,email,sender,content,fromer)最終變成這樣


Set jmail = Server.CreateObject("JMAIL.SMTPMail")
jmail.silent = true
jmail.logging = true
jmail.Charset = "GB2312"
jmail.ContentType = "text/html"
jmail.ServerAddress = [color=blue]"mail.ubbcn.com"[/color]
jmail.AddRecipient [color=blue]"runbing@eyou.com"[/color]
jmail.SenderName = [color=blue]"帥青蛙"[/color]
jmail.Sender = [color=blue]"runbing@eyou.com"[/color]
jmail.Priority = 1
jmail.Subject = [color=blue]"JMAIL發(fā)信" [/color]
jmail.Body = [color=blue]"這是一封測試郵件"[/color]
jmail.Execute()
jmail.Close


 



--------------------------------------------------------------------------------



下面是一個(gè)發(fā)信的例子,以HTML格式發(fā)不出信的關(guān)鍵問題是EMAIL地址要找對,另外一些大網(wǎng)站比如163.com在發(fā)信的時(shí)候需要設(shè)置發(fā)信信箱和密碼的,不認(rèn)證的話,有時(shí)候收不到信的
另外發(fā)信服務(wù)器最好是用企業(yè)郵局的,我用了幾個(gè)月,基本上都可以發(fā)信的
sendname = Request.Form ("name")
email= Request.Form ("email")
bh=Request.Form ("bh")
SystemEmail= Request.Form ("fmail")
pic = Request.Form ("pic")
mailbody="<html>"
mailbody=mailbody & "<title>&想您推薦一個(gè)產(chǎn)品</title>"
mailbody=mailbody & "<body>"
mailbody=mailbody & "<TABLE border=0 width='95%' align=center><TBODY><TR>"
mailbody=mailbody & "<TD valign=middle align=top>"
mailbody=mailbody &"您好:<br><br>"
mailbody=mailbody & "您的朋友("&sendname&")發(fā)送了一張圖片給你<br>"
mailbody=mailbody & "下面是相關(guān)信息:<br>"
mailbody=mailbody & "公司名稱:"&bh&"<br>"
mailbody=mailbody & "產(chǎn)品圖:<img src=http://www.szwin.net/chanpin/"&pic&" > <br>"
mailbody=mailbody & "<br><br>"
mailbody=mailbody & "<center><font color=red>希望您能選擇這個(gè)產(chǎn)品!</font>"
mailbody=mailbody & "</TD></TR></TBODY></TABLE><br><hr width=95% size=1>"
mailbody=mailbody & "</body>"
mailbody=mailbody & "</html>"
Set jmail = Server.CreateObject("JMail.Message")
jmail.silent = true
jmail.Logging = true
jmail.Charset = "gb2312"
JMail.ContentType = "text/html"
jmail.MailServerUserName ="123@szwin.net" '輸入smtp服務(wù)器驗(yàn)證登陸名 (郵局中任何一個(gè)用戶的Email地址)
jmail.MailServerPassword = "******" '輸入smtp服務(wù)器驗(yàn)證密碼 (用戶Email帳號對應(yīng)的密碼)
jmail.From = SystemEmail '發(fā)件人Email
jmail.FromName = sendname '發(fā)件人姓名
jmail.AddRecipient (email) '收件人Email
jmail.Subject = "想您推薦產(chǎn)品" '信件主題
jmail.Body = mailbody '正文
jmail.Send ("mail.szwin.net") 'smtp服務(wù)器地址(企業(yè)郵局地址)
set jmail = nothing
SendMailed = "OK"


如果大家想用文本的格式,可以用這個(gè)參考
每一行都會自動換行的
content = content & "用戶帳號:" & uid & vbcrlf
content = content & "用戶密碼:" & pwd & vbcrlf
content = content & "用戶郵件:" & email & vbcrlf
content = content & "用戶QQ:" & oicq & vbcrlf
content = content & "用戶地址:"& address & vbcrlf
content = content & "用戶電話:" & tel & vbcrlf
content = content & "用戶傳真:" & fax & vbcrlf
content = content & "注冊時(shí)間:" & cstr(now()) & vbcrlf
content = content &"信息服務(wù)由 "&homename&"提供("&homepage&")"& vbcrlf


下面是反饋表單的
<%
name = Request.Form ("gongsi")
name = Request.Form ("address")
name = Request.Form ("name")
email= Request.Form ("email")
phone= Request.Form ("phone")
mailsubject= Request.Form ("mailsubject")
text1= Request.Form ("text1")
%>
<%
mess = mess & "---------------客戶反饋意見開始-------------------" & vbcrlf
mess = mess & "發(fā)件人公司名稱:" & gongsi & vbcrlf
mess = mess & "發(fā)件人公司地址:" & address & vbcrlf
mess = mess & "發(fā)件人姓名:" & name & vbcrlf
mess = mess & "發(fā)件人郵件:" & email & vbcrlf
mess = mess & "發(fā)件人電話:" & phone & vbcrlf
mess = mess & "發(fā)件人內(nèi)容:" & text1 & vbcrlf
mess = mess & "---------------客戶反饋意見結(jié)束-------------------"
SystemEmail=Request.Form ("email")
sendname=Request.Form ("name")
Set jmail = Server.CreateObject("JMail.Message")
JMail.Priority = 1
JMail.Silent=true
JMail.Charset = "gb2312"
jmail.MailServerUserName ="123@szwin.net" '輸入smtp服務(wù)器驗(yàn)證登陸名 (郵局中任何一個(gè)用戶的Email地址)
jmail.MailServerPassword = "*******" '輸入smtp服務(wù)器驗(yàn)證密碼 (用戶Email帳號對應(yīng)的密碼)
jmail.From = SystemEmail '發(fā)件人Email
jmail.FromName = sendname '發(fā)件人姓名
jmail.AddRecipient "itpc@itpc.cn" '收件人Email
jmail.Subject = mailsubject '信件主題
jmail.Body = mess '正文
jmail.Send ("mail.szwin.net") 'smtp服務(wù)器地址(企業(yè)郵局地址)
set jmail = nothing
SendMailed = "OK"


%>
<Script language="javascript">
alert("郵件發(fā)送成功");
history.back();
</Script>


 


--------------------------------------------------------------------------------



下面老補(bǔ)充一個(gè)ASPEMAIL的
實(shí)例
sub sendMail(a_intID , a_strEmail)
const c_strMailServer = "smtp.163.net"
dim objConn,objRs,strSql
dim strContent,strBody,strSubject,objEmail


strBody = "<html><head>"
strBody = strBody + "<meta HTTP-EQUIV=Content-Type content=text/html; charset=gb2312>"
strBody = strBody + "</head><body bgColor=#d2b48c>"
strBody = strBody + "<a + "<img src=http://www.china-168.net/center/images/banner.gif border=0>" + "</a>"
strBody = strBody + "<h3 style='FONT-SIZE: 15px'>" + "請您確認(rèn)" + "</h>" + vbcrlf
strBody = strBody + "<p style='FONT-SIZE: 13px'>" + "您好<a href=mailto:"&a_strEmail&">"&a_strEmail&"</a>" + "</td>" + vbcrlf
strBody = strBody + "<p style='FONT-SIZE: 13px'>" + "歡迎您訂閱萬里信息網(wǎng)郵件列表" +"</td>"
strBody = strBody + "<p style='FONT-SIZE: 13px'>" + "為了防止出現(xiàn)訂閱錯誤,請您點(diǎn)擊以下鏈接進(jìn)行確認(rèn)。謝謝!" + "</td>"
strBody = strBody + "<p style='FONT-SIZE: 13px'>" + "<a href=""http://www.china-168.net/EmailList/affirm.asp?Mode=MailList&content="&a_strEmail&""">" + "請點(diǎn)擊這里,進(jìn)行訂閱確認(rèn)" + "</a>"
strBody = strBody + "<p style='FONT-SIZE: 13px'><a href=http://www.china-168.net target='_blank'>" + vbcrlf
strBody = strBody + "<img src=http://www.china-168.net/images/logo.gif"
strBody = strBody + " alt='更多信息盡在萬里信息網(wǎng)'></a><br>"
strBody = strBody + "<p style='FONT-SIZE: 13px'>" + "歡迎再次光臨萬里信息網(wǎng)!" + "</td>"
strBody = strBody + "</body></html>"


'發(fā)送email
on error resume next
set objEmail = server.CreateObject("Persits.MailSender")
objEmail.Host = c_strMailServer
objEmail.From = "jiabaoxu@163.net"
objEmail.FromName = "china-168.net"
objEmail.AddAddress a_strEmail
objEmail.Subject = "訂閱確認(rèn)"
objEmail.IsHTML = true
objEmail.CharSet = "gb2312"
objEmail.Body = strBody
objEmail.Send


'檢察錯誤
if Err.number = 0 then '如果成功
Response.Write ("<p align=center class=cn>為確保用戶不被騷擾,我們將發(fā)出確認(rèn)信,請?jiān)L問信中的URL以確認(rèn)登記</td>")
else '如果失敗則顯示出錯原因
Response.Write ("<p align=center class=cn>郵件發(fā)送出錯,錯誤原因:<br>")
Response.Write ("<font color=red>"&Err.Description&"</font></td>")
end if


'清場
set objEmail = nothing
end sub 使用該過程:
<%
.....RTSEmail GuestMailID,""&email&""
.....%>


--------------------------------------------------------------------------------
1、注意取得EMAIL的方法,這個(gè)很重要,另外注意
JMail.SMTPMail和JMAIL.Message一個(gè)是不需要用戶名稱
密碼認(rèn)證一個(gè)是需要!
2、最好設(shè)置認(rèn)證用戶名稱和密碼的,這樣可以保證發(fā)信的效率
我以前用不認(rèn)證的163.com sohu.com的免費(fèi)信箱很難收到信的!
3、注意各項(xiàng)參數(shù)正確,比如發(fā)信人姓名,發(fā)信人EMAIL,主題
如果有的參數(shù)取不到正確的值,也會收不到信的
另外綜合一個(gè)動網(wǎng)的BBS里面的發(fā)信代碼,讓大家加深一點(diǎn)印象
<%
sub Jmail(email,topic,mailbody)
on error resume next
dim JMail
Set JMail=Server.CreateObject("JMail.SMTPMail")
JMail.Logging=True
JMail.Charset="gb2312"
JMail.ContentType = "text/html"
JMail.ServerAddress=Forum_info(4)
JMail.Sender=Forum_info(5)
JMail.Subject=topic
JMail.Body=mailbody
JMail.AddRecipient email
JMail.Priority=1
'JMail.MailServerUserName = "shatan@dvbbs.net" '您的郵件服務(wù)器登錄名
'JMail.MailServerPassword = "nihaoma" '登錄密碼
JMail.Execute
Set JMail=nothing
if err then
SendMail=err.description
err.clear
else
SendMail="OK"
end if
end sub


sub Cdonts(email,topic,mailbody)
on error resume next
dim objCDOMail
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.From =Forum_info(5)
objCDOMail.To =email
objCDOMail.Subject =topic
objCDOMail.BodyFormat = 0
objCDOMail.MailFormat = 0
objCDOMail.Body =mailbody
objCDOMail.Send
Set objCDOMail = Nothing
if err then
SendMail=err.description
err.clear
else
SendMail="OK"
end if
end sub


sub aspemail(email,topic,mailbody)
on error resume next
dim mailer,recipient,sender,subject,message
dim mailserver,result
Set mailer=Server.CreateObject("ASPMAIL.ASPMailCtrl.1")
recipient=email
sender=Forum_info(5)
subject=topic
message=mailbody
mailserver=Forum_info(4)
result=mailer.SendMail(mailserver, recipient, sender, subject, message)
if err then
SendMail=err.description
err.clear
else
SendMail="OK"
end if
end sub


sub Emailbody(body)
Emailbody=Emailbody &"<style>A:visited { TEXT-DECORATION: none }"
Emailbody=Emailbody &"A:active { TEXT-DECORATION: none }"
Emailbody=Emailbody &"A:hover { TEXT-DECORATION: underline overline }"
Emailbody=Emailbody &"A:link { text-decoration: none;}"
Emailbody=Emailbody &"A:visited { text-decoration: none;}"
Emailbody=Emailbody &"A:active { TEXT-DECORATION: none;}"
Emailbody=Emailbody &"A:hover { TEXT-DECORATION: underline overline}"
Emailbody=Emailbody &"BODY { FONT-FAMILY: 宋體; FONT-SIZE: 14px;}"
Emailbody=Emailbody &"TD { FONT-FAMILY: 宋體; FONT-SIZE: 14px }</style>"
Emailbody=Emailbody &"<TABLE border=0 width='95%' align=center><TBODY><TR>"
Emailbody=Emailbody &"<TD valign=middle align=top>"
Emailbody=Emailbody & body
Emailbody=Emailbody &"</TD></TR></TBODY></TABLE><br><hr width=95% size=1>"
Emailbody=Emailbody & Copyright & " &nbsp;&nbsp; " & Version
Emailbody=mailbody
end sub
%>


該文章在 2011/4/8 0:20:00 編輯過
關(guān)鍵字查詢
相關(guān)文章
正在查詢...
點(diǎn)晴ERP是一款針對中小制造業(yè)的專業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國內(nèi)大量中小企業(yè)的青睞。
點(diǎn)晴PMS碼頭管理系統(tǒng)主要針對港口碼頭集裝箱與散貨日常運(yùn)作、調(diào)度、堆場、車隊(duì)、財(cái)務(wù)費(fèi)用、相關(guān)報(bào)表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點(diǎn),圍繞調(diào)度、堆場作業(yè)而開發(fā)的。集技術(shù)的先進(jìn)性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點(diǎn)晴WMS倉儲管理系統(tǒng)提供了貨物產(chǎn)品管理,銷售管理,采購管理,倉儲管理,倉庫管理,保質(zhì)期管理,貨位管理,庫位管理,生產(chǎn)管理,WMS管理系統(tǒng),標(biāo)簽打印,條形碼,二維碼管理,批號管理軟件。
點(diǎn)晴免費(fèi)OA是一款軟件和通用服務(wù)都免費(fèi),不限功能、不限時(shí)間、不限用戶的免費(fèi)OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved