
08/08/2002, 14:50
|
 | | | Fecha de Ingreso: junio-2002 Ubicación: No, en realidad, vivo desubicado.
Mensajes: 43
Antigüedad: 22 años, 10 meses Puntos: 0 | |
Re: Configuración de formmail <% '---------------------------------------------------------------------------
' Subroutines and functions.
'---------------------------------------------------------------------------
sub AddErrorMsg(msg)
dim n
'Add an error message to the list.
n = UBound(errorMsgs)
Redim Preserve errorMsgs(n + 1)
errorMsgs(n + 1) = msg
end sub
function GetHost(url)
Dim i, s
GetHost = ""
'Strip down to host or IP address and port number, if any.
if Left(url, 7) = "http://" then
s = Mid(url, 8)
elseif Left(url, 8) = "https://" then
s = Mid(url, 9)
end if
i = InStr(s, "/")
if i > 1 then
s = Mid(s, 1, i - 1)
end if
getHost = s
end function
function IsValidEmail(email)
dim names, name, i, c
'Check for valid syntax in an email address.
IsValidEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
IsValidEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
IsValidEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
IsValidEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
IsValidEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
IsValidEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
IsValidEmail = false
exit function
end if
if InStr(email, "..") > 0 then
IsValidEmail = false
end if
end function
function FormFieldList()
dim str, i, name
'Build an array of form field names ordered as they were received.
str = ""
for i = 1 to Request.Form.Count
for each name in Request.Form
if Left(name, 1) <> "_" and Request.Form(name) is Request.Form(i) then
if str <> "" then
str = str & ","
end if
str = str & name
exit for
end if
next
next
FormFieldList = Split(str, ",")
end function
function SendMail()
dim mailObj
dim addrList
'Send email based on mail component. Uses global variables for parameters
'because there are so many.
SendMail = ""
'Send email (CDONTS version), doesn't support reply to address and has
'no error checking.
if mailComp = "CDONTS" then
set mailObj = Server.CreateObject("CDONTS.NewMail")
mailObj.BodyFormat = 0
mailObj.MailFormat = 0
mailObj.From = fromAddr
mailObj.To = recipients
mailObj.Subject = subject
mailObj.Body = body
mailObj.Send
end if
'Send email (JMail version).
if mailComp = "JMail" then
set mailObj = Server.CreateObject("JMail.SMTPMail")
mailObj.Silent = true
mailObj.ServerAddress = smtpServer
mailObj.Sender = fromAddr
mailObj.ReplyTo = replyTo
mailObj.Subject = subject
addrList = Split(recipients, ",")
for each addr in addrList
mailObj.AddRecipient Trim(addr)
next
mailObj.ContentType = "text/html"
mailObj.Body = body
if not mailObj.Execute then
SendMail = "Email send failed: " & mailObj.ErrorMessage & "."
end if
end if
'Send email (ASPMail version).
if mailComp = "ASPMail" then
set mailObj = Server.CreateObject("SMTPsvg.Mailer")
mailObj.FromAddress = fromAddr
mailObj.RemoteHost = smtpServer
mailObj.ReplyTo = replyTo
for each addr in Split(recipients, ",")
mailObj.AddRecipient "", Trim(addr)
next
mailObj.Subject = subject
mailObj.ContentType = "text/html"
mailObj.BodyText = body
if not mailObj.SendMail then
SendMail = "Email send failed: " & mailObj.Response & "."
end if
end if
end function %> |