%
Set conn = Server.CreateObject("ADODB.Connection")
'hypothese dsn less
dbPath = Server.MapPath("../cgi-bin/contact.mdb")
'dbPath = Server.MapPath("PRODUITS.mdb")
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};" _
& " DBQ=" & dbPath
dim nom,prenom,testok,code,postalmarq,errmess,adresse,ville,pays,tel,email,demande,requete1
dim nommarq,Prenommarq,adressemarq,villemarq,telmarq,emailmarq
testok=1
Set objRE = New RegExp
objRE.Pattern = "@"
'------------------------------------------------------------------------------------------------
public function envoi_mail(boite)
on error resume next
dim retour
retour = VBCrLf
Const cdoSendUsingMethod = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort = 2
Const cdoSMTPServer = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic = 1
Const cdoSendUserName = "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword = "http://schemas.microsoft.com/cdo/configuration/sendpassword"
Dim objConfig ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields ' As ADODB.Fields
' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
' Set config fields we care about
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtp.wanadoo.fr"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
'.Item(cdoSendUserName) = "d"
'.Item(cdoSendPassword) = "d"
.Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.To = "ngenot@yahoo.fr,pastellistes@claranet.fr"
.From = "pastellistes@claranet.fr"
.Subject = "Contact Pastelliste de France"
.TextBody = Now()&retour& retour &nom & " " &prenom & retour &adresse& " " &retour& " " &code& " " & " " &ville& retour&retour& "Tel:" &tel& retour&retour& "Votre Demande:"&retour &demande& retour&retour& "Email:"&boite
.Send
End With
Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
end function
'------------------------------------------------------------------------------------------------
if Len(request.form("envoyer")) then
nom=request.form("nom")
prenom= request.form("prenom")
code= request.form("code")
adresse=request.form("adresse")
ville=request.form("Ville")
tel=request.form("tel")
email=request.form("email")
demande=request.form("demande")
if request.form("nom")="" then
testok=0
nommarq="Merci d'indiquer votre nom"
end if
if request.form("adresse")="" then
testok=0
adressemarq=" Merci d'indiquer votre adresse"
end if
if not isnumeric(request.form("code")) and request.form("code") <> "" then
testok=0
postalmarq="Code Postal incorrect"
end if
if request.form("Ville")="" then
testok=0
villemarq=" Merci d'indiquer votre Ville"
end if
if request.form("demande")="" then
testok=0
askmarq="Merci d'indiquer votre message"
end if
if not isnumeric(request.form("tel")) and request.form("tel") <> "" then
testok=0
telmarq="Indiquez uniquement des chiffres dans le champ téléphone"
end if
If objRE.Test(request.form("email")) = false Then
testok=0
emailmarq="E-mail incorrect"
end if
if testok=0 then
errmess="Merci de vérifier les champs marqués en rouge"
end if
if testok=1 then
requete1 = "insert into pastel (Nom_contact,Prenom_contact,Adresse_contact,Code_contact,Ville_contact,Email_contact,Tel_contact) values('" & nom & "','" & prenom & "','" & adresse & "','" & code & "','" & ville & "','" & email & "','" & tel & "')"
set recordset1=Server.CreateObject("ADODB.Recordset")
recordset1.Open requete1,conn
envoi_mail(email)
response.write ("")
end if
end if
if Len(request.form("annuler")) then
response.redirect("contact.asp")
end if
%>