Tavsiye
<%Dim objCDONTS Dim strFromName Dim strFromEmail, strToEmail Dim strSubject, strBody Dim strThisPage Dim strReferringPage Dim bValidInput strThisPage = Request.ServerVariables("SCRIPT_NAME")strReferringPage = Request.ServerVariables("HTTP_REFERER")' Debugging lines:'Response.Write strThisPage & "
" & vbCrLf'Response.Write strReferringPage & "
" & vbCrLf' Read in and set the initial values of our message parametersstrFromName = Trim(Request.Form("txtFromName"))strFromEmail = Trim(Request.Form("txtFromEmail"))strToEmail = Trim(Request.Form("txtToEmail"))strSubject = "Check out ASP 101!"strBody = Trim(Request.Form("txtMessage"))' I set the body message to a message that referenced the page the' user arrived from. This makes it great if you place a link to it' from your different articles, but can be weird if people link in' from other web sites.If strBody = "" ThenIf strReferringPage = "" Or InStr(1, strReferringPage, "www.prowww.net", 1) = 0 ThenstrBody = ""strBody = strBody & "Bu site harika bir site.Mutlaka gez..." & vbCrLfstrBody = strBody & vbCrLfstrBody = strBody & " http://www.prowww.net" & vbCrLfElsestrBody = ""strBody = strBody & "Bu siteyi mutlaka gezmelisin" & vbCrLfstrBody = strBody & vbCrLfstrBody = strBody & " " & strReferringPage & vbCrLfEnd IfEnd If' Quick validation just to make sure our parameters are somewhat validbValidInput = TruebValidInput = bValidInput And strFromName <> ""bValidInput = bValidInput And IsValidEmail(strFromEmail)bValidInput = bValidInput And IsValidEmail(strToEmail)' If valid send email and show thanks, o/w show formIf bValidInput Then' Set up our email object and send the messageSet objCDONTS = Server.CreateObject("CDONTS.NewMail")objCDONTS.From = strFromName & " <" & strFromEmail & ">"objCDONTS.To = strToEmailobjCDONTS.Subject = strSubjectobjCDONTS.Body = strBodyobjCDONTS.SendSet objCDONTS = Nothing' Show our thank you messageShowThanksMsgElseIf "http://" & Request.ServerVariables("HTTP_HOST") & strThisPage = strReferringPage ThenResponse.Write "Lutfen bos alan birakmayin.Mail adreslerini dogru yazin" & "
" & vbCrLfEnd If' Show our information retrieval formShowReferralForm strThisPage, strFromName, strFromEmail, strToEmail, strBodyEnd If' End of page logic... subs and functions follow! %><%' Subroutines and Functions that encapsulate some functionality' and make the above code easier to write... and read.' A quick email syntax checker. It's not perfect,' but it's quick and easy and will catch most of' the bad addresses than people type in.Function IsValidEmail(strEmail)Dim bIsValidbIsValid = TrueIf Len(strEmail) < 5 ThenbIsValid = FalseElseIf Instr(1, strEmail, " ") <> 0 ThenbIsValid = FalseElseIf InStr(1, strEmail, "@", 1) < 2 ThenbIsValid = FalseElseIf InStrRev(strEmail, ".") < InStr(1, strEmail, "@", 1) + 2 ThenbIsValid = FalseEnd IfEnd IfEnd IfEnd IfIsValidEmail = bIsValidEnd Function' I made this a function just to get it out of the' logic and make it easier to read. It just shows the' form that asks for the inputSub ShowReferralForm(strPageName, strFromName, strFromEmail, strToEmail, strBody)' I use script_name so users can rename this script witout having to change the code.%>
<%'
The Message to be sent:
'
Subject: < %= strSubject % >
'
Body: < %= strBody % >
End Sub' This just shows our thank you message... probably didn't need to' be a function, but since I made the form one I figured I'd do this' for consistency.Sub ShowThanksMsg()%>
<%End Sub%>