ASP發郵件功能可以通過引用CDOSYS組件來實現。具體步驟如下:
<%@ Language=VBScript %>
<%
Set objEmail = CreateObject("CDO.Message")
%>
<%
objEmail.From = "發件人郵箱"
objEmail.To = "收件人郵箱"
objEmail.Subject = "郵件主題"
objEmail.TextBody = "郵件內容"
%>
<%
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP服務器地址"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
%>
<%
objEmail.Send
%>
完整代碼示例:
<%@ Language=VBScript %>
<%
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "發件人郵箱"
objEmail.To = "收件人郵箱"
objEmail.Subject = "郵件主題"
objEmail.TextBody = "郵件內容"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP服務器地址"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
%>