<% '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 %> YES! Newsletter

Send this newsletter to a friend

">
Please fill out this brief form and click Send at the bottom of the page
to send this newsletter to a friend.

Your Name: " size="30" style="width:300px;">
Your Email: " size="30" style="width:300px;">
1st Friend's Email:
2nd Friend's Email:
3rd Friend's Email:
4th Friend's Email:
5th Friend's Email:
Additional Comments:


Please note that any email addresses you provide are not stored, and will be used only to send this newsletter to your friend(s). Read our privacy policy for details and reassurance.

Any questions/problems, please email yesnewsletters [at] yesmagazine.org.

<% else %> YES! Newsletter



Thank You! The newsletter has been sent.


/default.html">Return to Newsletter
<% end if %>