65.9K
CodeProject is changing. Read more.
Home

Send an email using ASP

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.43/5 (7 votes)

Apr 25, 2002

viewsIcon

114990

Send email with CDONTS

Introduction

This article shows how to send email from an ASP page using CDONTS Component.

Code snippet

Sub send_email(email_from, email_to, email_subject, email_body)
    Dim Newmail
    Set Newmail = server.CreateObject ("cdonts.newmail")
    
    Newmail.BodyFormat = 0
    Newmail.MailFormat = 0
    Newmail.From = email_from
    Newmail.To = email_to
    Newmail.Subject = email_subject
    Newmail.Body = email_body
    Newmail.Send
    
    Set Newmail = Nothing    
End Sub

To call the procedure:
Call send_email("from@domain.com","to@domain.com","Subject","Body")
If you have any difficulty using CDONTS, it is most often the configuration of the SMTP service on IIS. There is not much that can go wrong with this simple, yet extremely powerful component.