ASP Email
ASP provides support for sending emails programmatically using CDOSYS (Collaboration Data Objects for Windows). This is commonly used for sending notifications, confirmations, and other automated messages.
Key Topics
Sending a Basic Email
Example
<%
Dim objEmail
Set objEmail = Server.CreateObject("CDO.Message")
objEmail.To = "recipient@example.com"
objEmail.From = "sender@example.com"
objEmail.Subject = "Test Email"
objEmail.TextBody = "This is a test email sent from ASP."
objEmail.Send
Set objEmail = Nothing
Response.Write("Email sent successfully.")
%>
Explanation: This example creates an email message, sets the recipient, sender, subject, and body, and sends the email using the CDO.Message object.
Sending an HTML Email
Example
<%
Dim objEmail
Set objEmail = Server.CreateObject("CDO.Message")
objEmail.To = "recipient@example.com"
objEmail.From = "sender@example.com"
objEmail.Subject = "HTML Email"
objEmail.HTMLBody = "<h1>Welcome</h1><p>This is an HTML email.</p>"
objEmail.Send
Set objEmail = Nothing
Response.Write("HTML email sent successfully.")
%>
Explanation: This example demonstrates sending an email with HTML content using the HTMLBody property of the CDO.Message object.
Key Takeaways
- Use the
CDO.Messageobject to send emails programmatically in ASP. - HTML emails allow for rich formatting and content customization.
- Automated email notifications improve user engagement and communication.