ASP - Send Mail with CDONTS.NewMail

It is an simple to send email by asp script. The following is an example code for sending email via CDONTS.NewMail component.

	Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

objCDOMail.From = strFrom
objCDOMail.To = strTo
objCDOMail.Subject = strSubject
objCDOMail.Body = strBody

objCDOMail.Cc = ""
objCDOMail.Bcc = ""
objCDOMail.Importance = 1 '(0=Low, 1=Normal, 2=High)
objCDOMail.AttachFile "c:\path\filename.txt", "filename.txt"

objCDOMail.BodyFormat = 0 ' CdoBodyFormatHTML

'Outlook gives you grief unless you also set:
'objCDOMail.MailFormat = 0 ' CdoMailFormatMime

objCDOMail.Send

Set objCDOMail = Nothing

Where...

From is a sender email address
To is a email address who will receive this email
Subject is a email's subject
Body is a email's content

Cc (Carbon Copy) is a email address for who will receive this copy email in an Cc type
Bcc (Back Carbon Copy) is a email address for who will receive this copy email in an Bcc type
Importance is a mail emergency level subject to 3 levels (0=Low, 1=Normal, 2=High)
AttachFile is about to set the file sending with this email

BodyFormat is a type of this email's content format subject to 2 types (0=Text, 1=HTML)

Finally 'Send' function will let the email submit to the destination address