Example Code:
<%
dim objMail
set objMail = Server.CreateObject("Persits.MailSender")
'a valid SMTP server may a domain or IP
objMail.Host = "smtp-server.---.com"
objMail.From = "sender@---.com"
objMail.FromName = "senders name"
' ----- receiver -----
objMail.AddAddress "---@---.com", "Optional Recipient Name"
objMail.AddCC = "---@---.com"
objMail.AddBcc = "---@---.com"
objMail.AddAttachment = "c:\"
objMail.Subject = "Sending ASPEmail using Persits.MailSender"
objMail.Body = "Hi hello..This is a ASPEmail"
'---or--- html code ---
objMail.Body = "<html><body><h1>Hi hello..</h1>"
objMail.Body = objMail.Body &"<b>This is a ASPEmail</b>"
objMail.Body = objMail.Body &"</body></html>"
' set isHTML property to true
objMail.IsHTML = true
' ------------- check err ---------------
strErr = ""
bSuccess = False
On Error Resume Next ' catch errors
objMail.Send ' send message
set objMail=nothing 'empty memory
If Err <> 0 Then ' error occurred
strErr = Err.Description
' -------- go to other website page -------
response.redirect("error_message_page.htm")
' -------- or ----- show error message ----
response.write " no, email not sent out "
response.write "<br>Error occurred: <br>"&strErr
' -------- or do nothing -------
else
bSuccess = True
' ------ go to other website page ------
response.redirect("sucess_message_page.htm")
' -------- or --------
response.write " yes, email sent out "
End If
%>
--------------------------------------
to set isHTML property to False
is not necessary
objMail.IsHTML = False
----------ASPemail check error code ----------
<%
' ------------- check err ---------------
strErr = ""
bSuccess = False
On Error Resume Next ' catch errors
If Err <> 0 Then ' error occurred
strErr = Err.Description
' ------ go to other website page ------
response.redirect("error_message_page.htm")
' -------- or --------
response.write " no, email not sent out "
response.write "<br>Error occurred: <br>"&strErr
' -------- or do nothing ---------
else
bSuccess = True
' ------ go to other website page ------
response.redirect("sucess_message_page.htm")
' -------- or --------
response.write " yes, email sent out "
End If
%>
内有ASPemail错误讯息响应程序代码
可适用于跑完程序后响应结果
完成寄出或错误未寄出
|