CDONTS !! Dynamic Data in email

Discussion in 'ASP General' started by dave, Sep 13, 2004.

  1. dave

    dave Guest

    I am trying to generate an email from the webpage using code below, which
    works fine. However I want to be able to include some dyanmic data how do I
    go about it ?can anybody point me in the direction of some sample code ?

    Thanks Dave


    <%@ Language=VBScript %>
    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <%

    Dim myMail
    Dim HTML
    Set myMail = CreateObject("CDONTS.NewMail")

    HTML = "<!DOCTYPE HTML PUBLIC""-//IETF//DTD HTML//EN"">"
    HTML = HTML & "<html>"
    HTML = HTML & "<head>"
    HTML = HTML & "<meta http-equiv=""Content-Type"""
    HTML = HTML & "content=""text/html; charset=iso-8859-1"">"
    HTML = HTML & "<meta name=""GENERATOR"""
    HTML = HTML & " content=""Microsoft Visual Studio 6.0"">"
    HTML = HTML & "<title>HTMLMail</title>"
    HTML = HTML & "</head>"
    HTML = HTML & "<body bgcolor=""FFFFFF"">"
    HTML = HTML & "<IMG SRC=""http://www.microsoft.com/library/"
    HTML = HTML & "images/gifs/homepage/microsoft.gif"" BORDER=0 "
    HTML = HTML & "WIDTH=167 HEIGHT=36 ALT=""Microsoft Corporation"">"
    HTML = HTML & "<p><font size =""3"" face=""Arial""><strong>"
    HTML = HTML & "Microsoft Exchange CDONTS Example</strong></p>"
    HTML = HTML & "<p><font size =""2"" face=""Tahoma"">"
    HTML = HTML & "CDO for NTS allows an easy way to send mail.<br>"
    HTML = HTML & "This example shows how the content can be "
    HTML = HTML & "an HTML page<br>"
    HTML = HTML & "which allows you to send rich text and"
    HTML = HTML & "inline graphics.</p>"
    HTML = HTML & "</body>"
    HTML = HTML & "</html>"

    myMail.From=""
    myMail.To=""
    myMail.Subject="Sample CDONTS HTML Message"
    myMail.BodyFormat=0
    myMail.MailFormat=0
    myMail.Body=HTML
    myMail.Send
    set mymail=nothing
    Response.Write "Message Sent"
    %>
    </HEAD>
    <BODY>
    </BODY>
    </HTML>
    dave, Sep 13, 2004
    #1
    1. Advertising

  2. "dave" <> wrote in message
    news:ci4gq3$mha$...
    > I am trying to generate an email from the webpage using code below, which
    > works fine. However I want to be able to include some dyanmic data how do

    I
    > go about it ?can anybody point me in the direction of some sample code ?


    Dynamic how?

    Ray at home
    Ray Costanzo [MVP], Sep 13, 2004
    #2
    1. Advertising

  3. dave

    Dave Guest

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:...
    >
    > "dave" <> wrote in message
    > news:ci4gq3$mha$...
    > > I am trying to generate an email from the webpage using code below,

    which
    > > works fine. However I want to be able to include some dyanmic data how

    do
    > I
    > > go about it ?can anybody point me in the direction of some sample code ?

    >
    > Dynamic how?
    >
    > Ray at home
    >
    >

    Dyanmic in the sense of I want to be able to pull data from sql and display
    it in a formatted html table which in turn is embeded in an email message,
    basically like when you buy something online and you have a confirmation
    email showing what you ordered, that is what I want to be able to do. I may
    be going completly the wrong way about it due to my ignorance any help is
    gratefully received

    Dave
    Dave, Sep 14, 2004
    #3
  4. Do you know how to build a web-page that would display this data? If so,
    it's the same basic idea, except that instead of writing the html to a
    browser, you save it to a variable that will become the .HTMLBody of your
    CDO.Message object (assuming that's what you use).

    So, forget the e-mailing for a moment, and focus on just creating a web page
    with the data you want. Can you do that?

    Ray at work

    "Dave" <> wrote in message
    news:KAG1d.2253$...
    >>

    > Dyanmic in the sense of I want to be able to pull data from sql and
    > display
    > it in a formatted html table which in turn is embeded in an email message,
    > basically like when you buy something online and you have a confirmation
    > email showing what you ordered, that is what I want to be able to do. I
    > may
    > be going completly the wrong way about it due to my ignorance any help is
    > gratefully received
    >
    > Dave
    >
    >
    Ray Costanzo [MVP], Sep 14, 2004
    #4
  5. dave

    Dave Guest

    Thanks Ray,

    I can build an asp page that shows the data I require to be sent in the
    email , Just about ! :)

    What do I do next ?

    Dave

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:...
    > Do you know how to build a web-page that would display this data? If so,
    > it's the same basic idea, except that instead of writing the html to a
    > browser, you save it to a variable that will become the .HTMLBody of your
    > CDO.Message object (assuming that's what you use).
    >
    > So, forget the e-mailing for a moment, and focus on just creating a web

    page
    > with the data you want. Can you do that?
    >
    > Ray at work
    >
    > "Dave" <> wrote in message
    > news:KAG1d.2253$...
    > >>

    > > Dyanmic in the sense of I want to be able to pull data from sql and
    > > display
    > > it in a formatted html table which in turn is embeded in an email

    message,
    > > basically like when you buy something online and you have a confirmation
    > > email showing what you ordered, that is what I want to be able to do. I
    > > may
    > > be going completly the wrong way about it due to my ignorance any help

    is
    > > gratefully received
    > >
    > > Dave
    > >
    > >

    >
    >
    Dave, Sep 14, 2004
    #5
  6. Well, let's say that this is your page that returns data:

    page.asp:
    <html><head><title>something</title></head>
    <body>
    <%
    UserID = 6
    Dim oADO, oRS
    Set oADO = CreateObject("ADODB.Connection")
    Set oRS = oADO.Execute("SELECT COUNT(transID) FROM Trans WHERE UserID=" &
    UserID)
    %>
    You have placed <%=oRS.Fields.Item(0).Value%> orders.
    <%
    oRS.Close : Set oRS = Nothing
    oADO.Close : Set oADO = Nothing
    </body>
    </html>



    To turn that into an e-mail, you'd dump all the html to a variable, i.e.

    <%
    sBody = "<html><head><title>something</title></head>" & vbCrLf
    sBody = sBody & "<body>" & vbCrLf
    UserID = 6
    Dim oADO, oRS
    Set oADO = CreateObject("ADODB.Connection")
    Set oRS = oADO.Execute("SELECT COUNT(transID) FROM Trans WHERE UserID=" &
    UserID)
    sBody = sBody & "You have placed " & oRS.Fields.Item(0).Value & " orders." &
    vbCrLf
    oRS.Close : Set oRS = Nothing
    oADO.Close : Set oADO = Nothing
    sBody = sBody & "</body>" & vbCrLf
    sBody = sBody & "</html>"

    Set oCDO = CreateObject("CDO.Message")
    oCDO.From = ""
    oCDO.To = ""
    oCDO.Subject = "orders"
    oCDO.HtmlBody = sBody
    oCDO.Send
    %>

    Does that make sense?

    Ray at work




    "Dave" <> wrote in message
    news:0pH1d.2601$...
    > Thanks Ray,
    >
    > I can build an asp page that shows the data I require to be sent in the
    > email , Just about ! :)
    >
    > What do I do next ?
    >
    > Dave
    >
    > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    > message news:...
    >> Do you know how to build a web-page that would display this data? If so,
    >> it's the same basic idea, except that instead of writing the html to a
    >> browser, you save it to a variable that will become the .HTMLBody of your
    >> CDO.Message object (assuming that's what you use).
    >>
    >> So, forget the e-mailing for a moment, and focus on just creating a web

    > page
    >> with the data you want. Can you do that?
    >>
    >> Ray at work
    >>
    >> "Dave" <> wrote in message
    >> news:KAG1d.2253$...
    >> >>
    >> > Dyanmic in the sense of I want to be able to pull data from sql and
    >> > display
    >> > it in a formatted html table which in turn is embeded in an email

    > message,
    >> > basically like when you buy something online and you have a
    >> > confirmation
    >> > email showing what you ordered, that is what I want to be able to do. I
    >> > may
    >> > be going completly the wrong way about it due to my ignorance any help

    > is
    >> > gratefully received
    >> >
    >> > Dave
    >> >
    >> >

    >>
    >>

    >
    >
    Ray Costanzo [MVP], Sep 14, 2004
    #6
  7. dave

    dave Guest

    brilliant thankyou


    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:e$...
    >
    > Well, let's say that this is your page that returns data:
    >
    > page.asp:
    > <html><head><title>something</title></head>
    > <body>
    > <%
    > UserID = 6
    > Dim oADO, oRS
    > Set oADO = CreateObject("ADODB.Connection")
    > Set oRS = oADO.Execute("SELECT COUNT(transID) FROM Trans WHERE UserID=" &
    > UserID)
    > %>
    > You have placed <%=oRS.Fields.Item(0).Value%> orders.
    > <%
    > oRS.Close : Set oRS = Nothing
    > oADO.Close : Set oADO = Nothing
    > </body>
    > </html>
    >
    >
    >
    > To turn that into an e-mail, you'd dump all the html to a variable, i.e.
    >
    > <%
    > sBody = "<html><head><title>something</title></head>" & vbCrLf
    > sBody = sBody & "<body>" & vbCrLf
    > UserID = 6
    > Dim oADO, oRS
    > Set oADO = CreateObject("ADODB.Connection")
    > Set oRS = oADO.Execute("SELECT COUNT(transID) FROM Trans WHERE UserID=" &
    > UserID)
    > sBody = sBody & "You have placed " & oRS.Fields.Item(0).Value & " orders."
    > & vbCrLf
    > oRS.Close : Set oRS = Nothing
    > oADO.Close : Set oADO = Nothing
    > sBody = sBody & "</body>" & vbCrLf
    > sBody = sBody & "</html>"
    >
    > Set oCDO = CreateObject("CDO.Message")
    > oCDO.From = ""
    > oCDO.To = ""
    > oCDO.Subject = "orders"
    > oCDO.HtmlBody = sBody
    > oCDO.Send
    > %>
    >
    > Does that make sense?
    >
    > Ray at work
    >
    >
    >
    >
    > "Dave" <> wrote in message
    > news:0pH1d.2601$...
    >> Thanks Ray,
    >>
    >> I can build an asp page that shows the data I require to be sent in the
    >> email , Just about ! :)
    >>
    >> What do I do next ?
    >>
    >> Dave
    >>
    >> "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    >> message news:...
    >>> Do you know how to build a web-page that would display this data? If
    >>> so,
    >>> it's the same basic idea, except that instead of writing the html to a
    >>> browser, you save it to a variable that will become the .HTMLBody of
    >>> your
    >>> CDO.Message object (assuming that's what you use).
    >>>
    >>> So, forget the e-mailing for a moment, and focus on just creating a web

    >> page
    >>> with the data you want. Can you do that?
    >>>
    >>> Ray at work
    >>>
    >>> "Dave" <> wrote in message
    >>> news:KAG1d.2253$...
    >>> >>
    >>> > Dyanmic in the sense of I want to be able to pull data from sql and
    >>> > display
    >>> > it in a formatted html table which in turn is embeded in an email

    >> message,
    >>> > basically like when you buy something online and you have a
    >>> > confirmation
    >>> > email showing what you ordered, that is what I want to be able to do.
    >>> > I
    >>> > may
    >>> > be going completly the wrong way about it due to my ignorance any help

    >> is
    >>> > gratefully received
    >>> >
    >>> > Dave
    >>> >
    >>> >
    >>>
    >>>

    >>
    >>

    >
    >
    dave, Sep 15, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ivan divandelen

    Where i can find a Cdonts email component

    ivan divandelen, Sep 2, 2003, in forum: ASP General
    Replies:
    0
    Views:
    95
    ivan divandelen
    Sep 2, 2003
  2. Simon Wigzell

    CDONTS email time stamp

    Simon Wigzell, Dec 27, 2003, in forum: ASP General
    Replies:
    1
    Views:
    97
    Don Verhagen
    Dec 27, 2003
  3. Krishnan

    CDONTS email

    Krishnan, Jan 2, 2004, in forum: ASP General
    Replies:
    4
    Views:
    105
    Pratish
    Jan 2, 2004
  4. Jammer
    Replies:
    2
    Views:
    213
    Jeff Cochran
    Oct 17, 2004
  5. Todd Price
    Replies:
    0
    Views:
    129
    Todd Price
    Mar 16, 2005
Loading...

Share This Page