TheInsider
Programmer
Hello,
I have a website that is written with ASP 3. When a member registers on the site, I want to send them an e-mail containing data that pertains to that specific member. So I want to create a template e-mail body.
In *EVERY* example that I can find on sending e-mail with CDO for Win 2000, they concatenate a string for the HTMLBody property.
i.e.
This is hard to maintain because it is hard-coded. I can't just whip open FrontPage and make a quick change. Also, the code is not reusable between multiple pages. Anyway...
I would prefer to store the contents of the e-mail in another ASP page and then use ASP's wonderful ability to dynamically generate the output and attach it to the e-mail body.
i.e. a new page called test.asp:
This is great for maintenance... i.e. it's easier to modify and better fits the code-reusability rule. CDO supports the
function which loads an external page into the body. So I'm set... right?
Nope! CreateMHTMLBody works in Visual Basic, but when I use this function in ASP, the page hangs and eventually times out. Also, when tested in VB (because it's the only place where the code didn't hang) the query string data was ignored.
i.e.
would print:
So how can I store the e-mail body in another page, while still keeping it a template, and not concatenating strings, and using CDO for Win 2000.... as my XP Pro box doesn't seem to have the CDONTS library?
Thanks for any input,
The Insider
I have a website that is written with ASP 3. When a member registers on the site, I want to send them an e-mail containing data that pertains to that specific member. So I want to create a template e-mail body.
In *EVERY* example that I can find on sending e-mail with CDO for Win 2000, they concatenate a string for the HTMLBody property.
i.e.
Code:
Dim strHTMLBody
strHTMLBody = "<HTML>"
strHTMLBody = strHTMLBody & "<HTML>"
strHTMLBody = strHTMLBody & "<HEAD>"
strHTMLBody = strHTMLBody & "</HEAD>"
strHTMLBody = strHTMLBody & "<BODY>"
strHTMLBody = strHTMLBody & "</BODY>"
strHTMLBody = strHTMLBody & "</HTML>"
objCDO.HTMLBody = strHTMLBody
This is hard to maintain because it is hard-coded. I can't just whip open FrontPage and make a quick change. Also, the code is not reusable between multiple pages. Anyway...
I would prefer to store the contents of the e-mail in another ASP page and then use ASP's wonderful ability to dynamically generate the output and attach it to the e-mail body.
i.e. a new page called test.asp:
Code:
<HTML>
<HEAD>
</HEAD>
<BODY>
Welcome to my website, <%=Request.QueryString("YourName")%>.
This is my e-mail body!
</BODY>
</HTML>
This is great for maintenance... i.e. it's easier to modify and better fits the code-reusability rule. CDO supports the
Code:
CreateMHTMLBody
Nope! CreateMHTMLBody works in Visual Basic, but when I use this function in ASP, the page hangs and eventually times out. Also, when tested in VB (because it's the only place where the code didn't hang) the query string data was ignored.
i.e.
Code:
Dim m
set m = new CDO.Message
m.CreateMHTMLBody "[URL unfurl="true"]http://localhost/test.asp?YourName=bob"[/URL]
debug.print m.HTMLBody
Set m = Nothing
would print:
Code:
Welcome to my website, .
This is my e-mail body!
So how can I store the e-mail body in another page, while still keeping it a template, and not concatenating strings, and using CDO for Win 2000.... as my XP Pro box doesn't seem to have the CDONTS library?
Thanks for any input,
The Insider