<% Function checkemail(val) Dim objRegExp Set objRegExp = New RegExp objRegExp.Pattern = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$" checkemail = objRegExp.Test(val) Set objRegExp = Nothing end Function Function strfix(val) strfix=htmlencode(Trim(val)) end Function Function htmlencode(val) htmlencode=Server.HtmlEncode(val) end Function Function urlencode(val) urlencode=Server.URLEncode(val) end Function Function checkfname(val) Dim objRegExp Set objRegExp = New RegExp 'objRegExp.Pattern = "(apparently\s*-\s*to)|(bcc)|(boundary)|(charset)|(content\s*-\s*disposition)|(content\s*-\s*type)|(content\s*-\s*transfer\s*-\s*encoding)|(errors\s*-\s*to)|(in\s*-\s*reply\s*-\s*to)|(message\s*-\s*id)|(mime\s*-\s*version)|(multipart\s*/\s*mixed)|(multipart\s*/\s*alternative)|(multipart\s*/\s*related)|(reply\s*-\s*to)|(x\s*-\s*mailer)|(x\s*-\s*sender)|(x\s*-\s*uidl)" 'blnValid = objRegExp.Test(val) 'IF NOT blnValid Then checkfname = FALSE objRegExp.Pattern = "^[a-zA-Z''-'\s]{1,40}$" checkfname = objRegExp.Test(val) Set objRegExp = Nothing End Function dim strName, strEmail, strFdName(3),strFdEmail(3), errStr, FdEmailFound, i, dupEmailFound,j errStr="" FdEmailFound=false dupEmailFound=false strName = Trim(Request.Form("strName")) strEmail = Trim(Request.Form("strEmail")) strFdName(0) = Trim(Request.Form("strFdName1")) strFdName(1) = Trim(Request.Form("strFdName2")) strFdName(2) = Trim(Request.Form("strFdName3")) strFdEmail(0) = Trim(Request.Form("strFdEmail1")) strFdEmail(1) = Trim(Request.Form("strFdEmail2")) strFdEmail(2) = Trim(Request.Form("strFdEmail3")) if true then %> <%=(strName)%> <%=(strEmail)%> <%=(strFdName(0))%> <%=(strFdName(1))%> <%=(strFdName(2))%> <%=(strFdEmail(0))%> <%=(strFdEmail(1))%> <%=(strFdEmail(2))%> <% Response.end end if for i=0 to UBound(strFdName) if strFdName(i) <> "" then FdEmailFound = true for j=0 to UBound(strFdName) if i<>j and strFdEmail(i) = strFdEmail(j) and strFdEmail(i)<> null and strFdEmail(j) <> null then dupEmailFound = True end if Next Next if not FdEmailFound then errStr="Missing Friend's name or email" if dupEmailFound then errStr="Duplicated Friend's email" IF FdEmailFound then IF not checkfname(strName) Then errStr = "Invalid Name" IF not checkemail(strEmail) Then errStr = "Invalid email" IF not checkfname(strFdName(0)) Then errStr = "Invalid Friend's name 1" IF not checkfname(strFdName(1)) Then errStr = "Invalid Friend's name 2" IF not checkfname(strFdName(2)) Then errStr = "Invalid Friend's name 3" IF not checkemail(strFdEmail(0)) Then errStr = "Invalid Friend's email 1" IF not checkemail(strFdEmail(1)) Then errStr = "Invalid Friend's email 2" IF not checkemail(strFdEmail(2)) Then errStr = "Invalid Friend's email 3" End If if errStr ="" then Dim iMsg, iConf, Flds,schema, cdoConfig if true then Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") Set Flds = iConf.Fields schema = "http://schemas.microsoft.com/cdo/configuration/" dim alt alt = 1 if alt=0 then Flds.Item(schema & "sendusing") = 2 Flds.Item(schema & "smtpserver") = "smtp.live.com" Flds.Item(schema & "smtpserverport") = 25 Flds.Item(schema & "smtpauthenticate") = 1 Flds.Item(schema & "sendusername") = "messenger-express@live.com" Flds.Item(schema & "sendpassword") = "cyber911" Flds.Item(schema & "smtpusessl") = true Flds.Update else Flds.Item(schema & "sendusing") = 2 Flds.Item(schema & "smtpserver") = "smtp3.udomain.com.hk" Flds.Item(schema & "smtpserverport") = 25 Flds.Item(schema & "smtpauthenticate") = 1 Flds.Item(schema & "sendusername") = "smtp@bates141.com" Flds.Item(schema & "sendpassword") = "ba9648Te" Flds.Item(schema & "smtpusessl") = false Flds.Update end if for i=0 to UBound(strFdEmail) if(strFdEmail(i)<>"" and strFdName(i)<>"")then With iMsg '.To = "prime" .To = CStr(strFdName(i)&"<"&strFdEmail(i)&">") 'response.write(.To) .From = "messenger-express" .Subject = "MSN" .HTMLBody = "Hi "&strFdName(i)&",
Best Regards,"&strName&"" .Sender = "messenger-express@live.com" .Organization = "Microsoft" .ReplyTo = "messenger-express@live.com" Set .Configuration = iConf SendEmail = .Send End With end if Next set iMsg = nothing set iConf = nothing set Flds = nothing end if end if Response.AddHeader "Cache-Control","no-cache" 'Response.ContentType = "application/xml" %> <%IF (errStr <>"") and (FdEmailFound) Then%> <%=errStr%> 0 <%ElseIf not FdEmailFound then %> <%=errStr%> 0 <%ElseIf dupEmailFound then%> <%=errStr%> 0 <%Else%> 1 <%End If%>