%
'on error resume next
dim Mail, Body
dim fso, physical_path, oTF
dim MailFrom,MailTo,MailSubject,MailBody
function EmailAddressOK(add)
' check the submitted address to see if it's a good one or not...
dim AtSign, FirstDot
AtSign = instr(add, "@")
if AtSign > 0 then
FirstDot = instr(AtSign, add, ".")
if FirstDot > 0 then
if AtSign >= 2 and FirstDot >= (AtSign + 2) and len(add) >= (FirstDot + 2) then
EmailAddressOK = true
else
EmailAddressOK = false
end if
else
EmailAddressOK = false
end if
else
EmailAddressOK = false
end if
end function
if trim(request("Act")) <> "" then
if trim(request("FromEmail")) <> "" and EmailAddressOK(trim(request("FromEmail"))) then
MailFrom = trim(request("FromEmail")) '"yesnewsletters@yesmagazine.org"
else
MailFrom = "yesnewsletters@yesmagazine.org"
end if
''ADD LOOP OVER 5 EMAILS HERE
for i = 1 to 5
''Response.write("To Email" & i & ": " & request("ToEmail"&i))
if trim(request("ToEmail" & i)) <> "" and EmailAddressOK(trim(request("ToEmail" & i))) then
MailTo = trim(request("ToEmail"&i))
MailSubject = "YES! Magazine's Newsletter"
set fso = createobject("scripting.filesystemobject")
physical_path = server.mappath(trim(request("Issue"))&"/default.html")
'
if fso.FileExists(physical_path) then
set oTF = fso.OpenTextFile(physical_path)
Body = trim(oTF.ReadAll)
oTF.Close
Body = replace(Body,"","
This newsletter was forwarded to you by: "&trim(request("FromName"))&"
"&trim(request("Comments"))&"
")
MailBody = Body
SendEmail MailFrom,MailTo,"",MailSubject,MailBody,"HTML",""
'Response.write("Mail " & i & " sent
") else 'Response.write("Could not find file
") end if set oTF = nothing set fso = nothing end if 'set fso = createobject("scripting.filesystemobject") 'set ofsfile = fso.opentextfile(server.mappath("\foo\foo.txt"), 2) 'ofsfile.writeLine("Email body send " & now) 'ofsfile.write(Body) 'ofsfile.close 'set ofsfile = nothing 'set fso = nothing Next ''END LOOP end if if trim(request("Act")) = "" then %>
Thank You! The newsletter has been sent. /default.html">Return to Newsletter |