Sending Email in ASP

May 9, 2009 by satz  
Filed under ASP, Scripts

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 .

  • Leave a Comment

    Leave your sincere comments and feed backs below. It helps us to improve the quality and encourages us to do more.

Speak Your Mind

Tell us what you're thinking...
All the support requests shall be posted at forum.tutorials2learn.com