View Full Version : HTML Page through CDO

01-11-2008, 04:36 PM
Hello all. I am trying to send a dynamic ASP page thorugh and email using CDO, but I am having trouble figuring out how to call it. I have the following script:

Set oMail = Server.CreateObject("CDO.Message")
Set oMailConfig = Server.CreateObject ("CDO.Configuration")

oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpout.myserver.net"
oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

Set oMail.Configuration = oMailConfig
oMail.From = "me@myemail.com"
oMail.To = "you@youremail.com"
oMail.Cc = ""
oMail.Bcc = ""
oMail.Subject = "Project and Task DELETED"
oMail.HTMLBody = "/email_Planned_Work_(form).asp?UserId="& Session(MM_Username)

Set oMail = Nothing
Set oMailConfig = Nothing

I have also tried
oMail.HTMLBody = "www.mywebsite.com/rpts/email_Planned_Work_(form).asp? and the only thing I am getting is the following in the email:


I have read about using CreateMHTMLBody, but then I get the error that the command isn't supported.

Any help would be greatly appreciated.


01-11-2008, 05:54 PM
I'm not sure you can do this the way you want to.

Here is how I would do it:

Open the web page file (shown as test.txt) in a text stream then with each line and it to oMail.HTMLBody

Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("test.txt"), 1)

do while f.AtEndOfStream = false
oMail.HTMLBody = oMail.HTMLBody & f.ReadLine

Set f=Nothing
Set fs=Nothing

But the page that is read would have to be static. It cannot be an asp page as no preprocessing can be done... if you catch my drift!

01-11-2008, 06:18 PM
Thank you for your response. But, even with the simples code:

<table border="0" cellspacing="0" cellpadding="0">

<td width="90" bgcolor="#000000"><div align="left"><span class="style9">Type of Work </span> </div></td>
<td width="90" bgcolor="#000000"><div align="left"><span class="style9">Day of Week </span> </div></td>
<td width="110" bgcolor="#000000"><div align="left"><span class="style9">Project</span> </div></td>
<td width="150" bgcolor="#000000"><div align="left"><span class="style9">Description</span> </div></td>
<td width="50" bgcolor="#000000"><div align="left"><span class="style9">Hours</span> </div></td>
<td width="90" bgcolor="#000000"><div align="left"><span class="style9">Status</span> </div></td>
<td width="150" bgcolor="#000000"><div align="left"><span class="style9">Comments</span> </div></td>


... i get the following error:

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/rpts/email_Planned_Work.asp, line 165

Am I missing something?



01-11-2008, 07:35 PM
Please post line 165

EDIT: Just tested it with the code you have provided and it works fine for me.

01-11-2008, 08:46 PM
Actually, after some rearranging things, removing some quotes, and just starting from a clean slate instead of trying to convert an existing page, I was finally able to get it.

Thank you so much for your help in this matter.


01-11-2008, 09:15 PM
Glad I could help ;)