In this article we learn how to send an email message in ASP. We use CDOSYS component in ASP to send email.
CDOSYS is a built-in component in ASP. This component is used to send e-mails with ASP.
Sending an email in HTML format:
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.HTMLBody = "<h1>This is a message.</h1>"
myMail.Send
set myMail=nothing
%>
Code Explained:
Set myMail=CreateObject(“CDO.Message”) : Creates an Object on the server with the name “myMail“.
myMail.Subject : The created mail Object gets the subject.
myMail.From : The from Id of the mail is specified.
myMail.To : The to Id is specified.
myMail.HTMLBody : The HTML body of the email. We can use html tags.
myMail.Send : the mail object is send.
set myMail=nothing : Once the mail is sent, we need to destroy the mail object .