ASP Classic HTML Emailer

This little classic ASP code snippet allows you to send nicely-formatted HTML E-mail apart from Outlook or other software that often adds its own extraneous code. Additionally, this method of sending HTML email is much more usable that the Outlook method of embedding images, since it allows the user to decide whether or not to link to the external images and thus greatly reduces the size of your e-mails.

'Simple HTML Emailer - Shaun Geisert
'This little vbscript snippet reads a given file and e-mails the contents of the file to an e-mail address.
'This allows you to send cleanly-coded (as opposed to using Outlook/Word, eg) HTML files with linked images
'and not embedded images.  Be sure to use absolute URLs (eg, when
'referencing graphics, and include a valid HTML file in the same directory as this script.
'Define some vars
dim myToEmail, myFromEmail, mySubject, mySTMPServer, myFile, myServer

mySubject = "SUBJECT_HERE"

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(Server.MapPath(myFile), ForReading)

'Grab file contents
Do Until objTextFile.AtEndOfStream
strMessage = objTextFile.ReadAll

'Compose e-mail
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item("") = 2
.Item("") = mySMTPServer
End With

Set objEmail = CreateObject("CDO.Message")
With objEmail
Set .Configuration = cdoConfig
.From = myFromEmail
.To = myToEmail
.Subject = mySubject
.HTMLBody = strMessage
End With

'Provide user feedback
Response.Write("Your HTML e-mail was successfully sent to " & myToEmail & "!  Send it again!")