<%@LANGUAGE="VBSCRIPT" CodePage=65001%>
<%Option Explicit%>
<%Session.CodePage="65001"%>
<SCRIPT LANGUAGE=vbscript RUNAT=Server>
Function mailcorrector(matn2)
Dim mabo_cont
Dim matn3
matn3=""
For mabo_cont=1 to Len(matn2)
matn3=matn3 & "&#" & Ascw(Mid(matn2,mabo_cont,1)) & ";"
Next
mailcorrector=matn3
End Function
</SCRIPT>
<%
'########## in ghesmat baraye darje fom dar database mibashad. ##########
Dim oconn
Dim ors
Dim filepath
filepath=Server.MapPath("database/contact.mdb")
Set oconn=Server.CreateObject("ADODB.Connection")
oconn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filePath
Set ors=oconn.Execute("SELECT ID from contact_tbl")
Dim sql2_str
sql2_str="'" & Request.Form("name") & "','" & Request.Form("family") & "','" & Request.Form("company") & "','" & Request.Form("phone") & "','" & Request.Form("select") & "','" & Request.Form("chek1") & "','" & Request.Form("chek2") & "','" & Request.Form("chek3") & "','" & Request.Form("radio") & "','" & Request.Form("email") & "','" & Request.Form("website") & "','" & Request.Form("message") & "'"
oconn.Execute "INSERT INTO contact_tbl (name_fld,family_fld,company_fld,phone_fld,select_fld,check1_fld,check2_fld,check3_fld,radio_fld,email_fld,website_fld,message_fld) VALUES (" & sql2_str & ")"
ors.close
oconn.close
Set ors=Nothing
Set oconn=Nothing
%>
<%
'########## in ghesmat baraye ettelarasani be email mibashad ##########
Dim objMail
Dim objConf
Dim objFields
Dim mailto_txt
Dim mailfrom_txt
Dim mailsubject_txt
Dim mailserver_txt
Dim mailbody_txt
mailto_txt="[email protected]"
mailfrom_txt="[email protected]"
mailsubject_txt="New Contact"
mailserver_txt="127.0.0.1"
mailbody_txt="Hello"
mailbody_txt=mailbody_txt & vbCrLf & "You have new contact in your site:"
mailbody_txt=mailbody_txt & vbCrLf & "Name: " & mailcorrector(Request.Form("name"))
mailbody_txt=mailbody_txt & vbCrLf & "family: " & mailcorrector(Request.Form("family"))
mailbody_txt=mailbody_txt & vbCrLf & "company: " & mailcorrector(Request.Form("company"))
mailbody_txt=mailbody_txt & vbCrLf & "phone: " & mailcorrector(Request.Form("phone"))
mailbody_txt=mailbody_txt & vbCrLf & "select: " & mailcorrector(Request.Form("select"))
mailbody_txt=mailbody_txt & vbCrLf & "check1: " & mailcorrector(Request.Form("chek1"))
mailbody_txt=mailbody_txt & vbCrLf & "check2: " & mailcorrector(Request.Form("chek2"))
mailbody_txt=mailbody_txt & vbCrLf & "check3: " & mailcorrector(Request.Form("chek3"))
mailbody_txt=mailbody_txt & vbCrLf & "radio: " & mailcorrector(Request.Form("radio"))
mailbody_txt=mailbody_txt & vbCrLf & "email: " & mailcorrector(Request.Form("email"))
mailbody_txt=mailbody_txt & vbCrLf & "website: " & mailcorrector(Request.Form("website"))
mailbody_txt=mailbody_txt & vbCrLf & "message: " & mailcorrector(Request.Form("message"))
Set objMail=Server.CreateObject("CDO.Message")
Set objConf=Server.CreateObject("CDO.Configuration")
Set objFields=objConf.Fields
With objFields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")=mailserver_txt
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")=10
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
.Update
End With
With objMail
Set .Configuration=objConf
.From=mailfrom_txt
.To=mailto_txt
.Subject=mailsubject_txt
.TextBody=mailbody_txt
End With
Err.Clear
On Error Resume Next
objMail.Send
Set objFields=Nothing
Set objConf=Nothing
Set objMail=Nothing
%>
<%
Response.Redirect("thanks.html")
%>