<% ' Declare variable pour le formulaire Dim strTo, strSubject, strBody,strIp, strMail 'Strings for recipient, subject, boby Dim objCDOMail 'The CDO object 'First we'll read in the values entered strSubject = "Site Internet, Formulaire Contact" strIp = Request.ServerVariables("REMOTE_ADDR") strMail = Request.Form("Email") strBody = strBody & vbCrLf strBody = strBody & "Type de Visiteur : " & Request.Form("Who") strBody = strBody & vbCrLf strBody = strBody & "Nom : " & Request.Form("FirstName") strBody = strBody & vbCrLf strBody = strBody & "Prénom " & Request.Form("LastName") strBody = strBody & vbCrLf strBody = strBody & "Pays : " & Request.Form("Country") strBody = strBody & vbCrLf strBody = strBody & "Email : " & Request.Form("Email") strBody = strBody & vbCrLf strBody = strBody & "Commentaires : " & Request.Form("Comments") strBody = strBody & vbCrLf strBody = strBody & strIp strTo = "mlewintre@twf-foods.com" ' Some spacing: strBody = strBody & vbCrLf & vbCrLf strBody = strBody & "Ce message a été envoyé par: " strBody = strBody & Request.Form("Email") strBody = strBody & vbCrLf If strMail = "" Or Not IsValidEmail(strMail) Then %> TWF Contact
 

 

 

 
  Mr. Alain MORON
President & CEO

alainmoron@twf-foods.com
 
<% Else ' Create an instance of the NewMail object. Set objCDOMail = Server.CreateObject("CDONTS.NewMail") ' Set the properties of the object '*********************************************************** ' PLEASE CHANGE THESE SO WE DON'T APPEAR TO BE SENDING YOUR ' EMAIL. WE ALSO DON'T WANT THE EMAILS TO GET SENT TO US ' WHEN SOMETHING GOES WRONG WITH YOUR SCRIPT... THANKS '*********************************************************** ' This syntax works fine 'objCDOMail.From = "mlewintre@twf-foods.com" ' But this gets you the appearance of a real name! objCDOMail.From = "Site Web TWF " objCDOMail.To = "mlewintre@twf-foods.com" objCDOMail.Subject = strSubject objCDOMail.Body = strBody ' There are lots of other properties you can use. ' You can send HTML e-mail, attachments, etc... ' You can also modify most aspects of the message ' like importance, custom headers, ... ' Check the documentation for a full list as well ' as the correct syntax. ' Some of the more useful ones I've included samples of here: 'objCDOMail.Cc = "user@domain.com;user@domain.com" 'objCDOMail.Bcc = "user@domain.com;user@domain.com" 'objCDOMail.Importance = 1 '(0=Low, 1=Normal, 2=High) 'objCDOMail.AttachFile "c:\path\filename.txt", "filename.txt" ' I've had several requests for how to send HTML email. ' To do so simply set the body format to HTML and then ' compose your body using standard HTML tags. 'objCDOMail.BodyFormat = 0 ' CdoBodyFormatHTML 'Outlook gives you grief unless you also set: 'objCDOMail.MailFormat = 0 ' CdoMailFormatMime ' Send the message! objCDOMail.Send ' Set the object to nothing because it immediately becomes ' invalid after calling the Send method. Set objCDOMail = Nothing Response.Redirect "validation.asp" 'Response.Write "Message sent to Tradional World Foods!" End If ' End page logic %> <% ' Only functions and subs follow! ' 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 bIsValid bIsValid = True If Len(strEmail) < 5 Then bIsValid = False Else If Instr(1, strEmail, " ") <> 0 Then bIsValid = False Else If InStr(1, strEmail, "@", 1) < 2 Then bIsValid = False Else If InStrRev(strEmail, ".") < InStr(1, strEmail, "@", 1) + 2 Then bIsValid = False End If End If End If End If IsValidEmail = bIsValid End Function %>