Tuesday, December 21, 2004

Send mail with body content reading from HTML page

The code here has two parts

1. Reading contents of HTML page into a string [say, strContent]

2. Sending mail with body of the mail as strContent



Part 1

' File System Object

set objFSO = CreateObject("Scripting.FileSystemObject")

set objFile = objFSO.GetFile(Server.MapPath("./HtmlTest.html"))

set objStream = objFile.OpenAsTextStream(1) ' parameter 1 for reading

strContent = objStream.ReadAll



Part 2

Dim Mail


set Mail = CreateObject("CDONTS.NewMail")

Mail.From= "from@from.com"

Mail.To= "to@to.com"

Mail.Subject="Subject"

Mail.Body=strContent

Mail.Send

set Mail=nothing


No comments: