Click to See Complete Forum and Search --> : help me pleaseeee!!


GreyFilmPro
06-15-2006, 07:10 PM
Can someone give me an .asp script that will send the form fields to my e-mail and redirect the viewer to the page saying there message has been sent. I know how to do the ( form action="script.asp" ) but I dont know how to make the asp script.

russell
06-16-2006, 01:55 AM
ok, since you know how to do action="script.asp" then this is what to put in script.asp.

Comment out the on error resume next while testing

<%
Response.ExpiresAbsolute = Date()-1

Dim f
Dim subject
Dim body
Dim strErr

subject = "A message"
body = ""

For Each f in Request.Form
body = f & ":" & vbTab & Request.Form(f) & vbCrLf
Next

If SendMail(subject, body, strErr) Then
Response.Write "Mail Sent"
Else
Response.Write "Error Sending mail<br>"
Response.Write "<span style=color:red>" & strErr & "</span>"
End If

Function SendMail(byVal subject, byVal body, byRef strErr)
Dim ObjSendMail
Dim iConf
Dim Flds

On Error Resume Next

Set ObjSendMail = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")

Set Flds = iConf.Fields
With Flds
.Item(cdoSendUsingMethod) = 2
.Item(cdoSMTPServer) = "Server_Name_Or_IP_address"
.Item(cdoSMTPServerPort) = 25
.Update
End With

Set ObjSendMail.Configuration = iConf

Set ObjSendMail.Configuration = iConf
ObjSendMail.To = "you@there.com"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "me@here.com"

' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"

ObjSendMail.Send

SendMail = True

Set ObjSendMail = Nothing
Set iConf = Nothing
Set Flds = Nothing

If Err.number <> 0 Then
strErr = Err.number & " " & Err.Description
SendMail = False
Err.Clear
End If

On Error Goto 0
End Function
%>