Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > CDONTS !! Dynamic Data in email

Reply
Thread Tools

CDONTS !! Dynamic Data in email

 
 
dave
Guest
Posts: n/a
 
      09-13-2004
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>


 
Reply With Quote
 
 
 
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      09-13-2004

"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


 
Reply With Quote
 
 
 
 
Dave
Guest
Posts: n/a
 
      09-14-2004
"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


 
Reply With Quote
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      09-14-2004
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
>
>



 
Reply With Quote
 
Dave
Guest
Posts: n/a
 
      09-14-2004
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
> >
> >

>
>



 
Reply With Quote
 
Ray Costanzo [MVP]
Guest
Posts: n/a
 
      09-14-2004

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
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
dave
Guest
Posts: n/a
 
      09-15-2004
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
>>> >
>>> >
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using CDONTS to send Japanese (UTF-8) email message Todd Price ASP General 0 03-16-2005 09:17 PM
How do I use CDONTS.new to send an email with attachment? Jammer ASP General 2 10-17-2004 06:02 PM
CDONTS email Krishnan ASP General 4 01-02-2004 08:41 PM
CDONTS email time stamp Simon Wigzell ASP General 1 12-27-2003 06:05 PM
Where i can find a Cdonts email component ivan divandelen ASP General 0 09-02-2003 07:59 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57