By html page in asp sending mail
A classic combination!
To send an email from an HTML page in ASP, you'll need to use a combination of HTML, ASP, and a mail server. Here's a step-by-step guide:
Step 1: Create an ASP page
Create a new ASP page (e.g., sendmail.asp
) and add the following code:
<%
' Set the email server settings
Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
objMail.From = "[email protected]"
objMail.To = "[email protected]"
objMail.Subject = "Test Email from ASP"
objMail.TextBody = "This is a test email sent from an ASP page."
' Set the mail 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
' Save and send the email
objMail.Send
Set objMail = Nothing
%>
Replace the placeholders with your actual email server settings:
[email protected]
: Your email address[email protected]
: The recipient's email addressyour_smtp_server
: Your email server's hostname or IP address25
: The port number used by your email server (usually 25 or 587)
Step 2: Create an HTML page
Create a new HTML page (e.g., index.html
) and add a form that submits to the ASP page:
<!DOCTYPE html>
<html>
<head>
<title>Send Email</title>
</head>
<body>
<form action="sendmail.asp" method="post">
<input type="text" name="email" placeholder="Recipient's email">
<input type="submit" value="Send Email">
</form>
</body>
</html>
Step 3: Test the email sending
Open the HTML page (index.html
) in a web browser and fill in the recipient's email address. Click the "Send Email" button to send the email.
Note: Make sure your ASP page is configured to run on the same server as your HTML page, and that the ASP page has the necessary permissions to send emails.
That's it! With these steps, you should be able to send an email from an HTML page in ASP.