Asp form mail script
Here is an example of an ASP form mail script that sends an email using the Mail
object in ASP:
<%
' Set the form variables
Dim name, email, message
name = Request.Form("name")
email = Request.Form("email")
message = Request.Form("message")
' Set the email settings
Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
objMail.From = "[email protected]"
objMail.To = "[email protected]"
objMail.Subject = "Form Submission from " & name
objMail.TextBody = "Name: " & name & vbCrLf & "Email: " & email & vbCrLf & "Message: " & message
' Set the email server settings
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "your_smtp_server"
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMail.Configuration.Fields.Update
' Send the email
objMail.Send
' Clean up
Set objMail = Nothing
%>
This script assumes that you have a form with the following fields:
name
: a text input field for the user's nameemail
: a text input field for the user's email addressmessage
: a text area field for the user's message
The script uses the Mail
object to create a new email message and sets the From
, To
, Subject
, and TextBody
properties accordingly. It then sets the email server settings using the Configuration
object and sends the email using the Send
method.
You'll need to replace the placeholders ([email protected]
, [email protected]
, your_smtp_server
, and 25
) with your own email address, recipient email address, SMTP server, and port number.
Note that this script uses the CDO
(Collaboration Data Objects) component to send the email. This component is included with IIS (Internet Information Services) and is used to send emails using the SMTP protocol.
Also, make sure to test the script in a development environment before deploying it to a production server, as it may require additional configuration or modifications to work correctly.