Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Email variables with cdo

    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.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New to the CF scene
    Join Date
    Aug 2004
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks Roy

    Thanks Roy that worked fine.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •