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.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <% '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, www.parents.colostate.edu/images/myimage.gif) 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 myToEmail = "EMAIL_ADDRESS_HERE" myFromEmail = "EMAIL_ADDRESS_HERE" mySubject = "SUBJECT_HERE" mySMTPServer = "SMPT_SERVER_HERE" myFile = "FILENAME_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 Loop %> <% 'Compose e-mail Set cdoConfig = CreateObject("CDO.Configuration") With cdoConfig.Fields .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mySMTPServer .Update End With Set objEmail = CreateObject("CDO.Message") With objEmail Set .Configuration = cdoConfig .From = myFromEmail .To = myToEmail .Subject = mySubject .HTMLBody = strMessage .Send End With 'Provide user feedback Response.Write("Your HTML e-mail was successfully sent to " & myToEmail & "! Send it again!") %>