<% inputMailTo = Trim(Request.Form("inputMailTo")) inputMailFrom = Trim(Request.Form("inputMailFrom")) inputMailSubject = Trim(Request.Form("inputMailSubject")) textBoxMailBody = Trim(Request.Form("textBoxMailBody"))
dim ErrMsgInputMailTo,ErrMsgInputMailFrom,ErrMsgInputMailSubject,ErrMsgTextBoxMailBody,MsgSendResult
sendMail
sub sendMail() if inputMailTo = "" then ErrMsgInputMailTo = "不能为空" exit sub end if if ValidateEmail(inputMailTo) = false then ErrMsgInputMailTo = "E-Mail Address Error" exit sub end if if inputMailFrom = "" then ErrMsgInputMailFrom = "不能为空" exit sub end if if ValidateEmail(inputMailFrom) = false then ErrMsgInputMailFrom = "E-Mail Address Error" exit sub end if if inputMailSubject = "" then ErrMsgInputMailSubject = "不能为空" exit sub end if if textBoxMailBody = "" then ErrMsgTextBoxMailBody = "不能为空" exit sub end if
Set mail = Server.CreateObject("CDONTS.NewMail") mail.To = inputMailTo mail.From = inputMailFrom mail.Subject = inputMailSubject mail.Body = textBoxMailBody mail.Send
MsgSendResult = "发送成功!From: " + inputMailFrom + "; To: " + inputMailTo
end sub %>
发送邮件 By ASP
<% Function ValidateEmail(Expression) Dim objRegExp Set objRegExp = New RegExp objRegExp.Pattern = "^[\w\.-]+@[\w\.-]+\.[a-zA-Z]+$" ValidateEmail = objRegExp.Test(Expression) End Function %>
|