...

View Full Version : Email variables with cdo



RickyCodeF
08-27-2004, 08:14 PM
How do I email session variables in body of email
example--------------------------------------->
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="HELP"
myMail.From="someone@somewhere.com"
myMail.To="someone@somewhere.com"
'---------------------------------------------------------->
'Do not which to use if any. I want to put the variables in the body of the email.

myMail.CreateMHTMLBody =Session("var")
myMail.HTMLBody = "<h1>=Session("var")</h1>"
myMail.TextBody="=(session("var"))"
'----------------------------------------------------------------->
myMail.Send
set myMail = nothing
%>

Thanks in advance for any help.

Roy Sinclair
08-27-2004, 08:39 PM
This will work but it'll be a short email unless the var is huge:

myMail.CreateMHTMLBody = Session("var")

This is wrong because the <%=expression%> output is appropriate for adding a bit of output to html but when you're already in script mode, you don't get a switch. You also have incorrectly nested quote marks which would cause that statement to fail anyway.

myMail.HTMLBody = "<h1>=Session("var")</h1>"

it would work if written as

myMail.HTMLBody = "<h1>" & Session("var") & "</h1>"

Lastly this one has the same problems as the previous one:

myMail.TextBody="=(session("var"))"

this one should be:

myMail.TextBody= session("var")


Did that make sense?

RickyCodeF
08-27-2004, 09:15 PM
Thanks Roy that worked fine.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum