html cdonts from access

This is a discussion on "html cdonts from access" within the Classic ASP section. This forum, and the thread "html cdonts from access are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old May 27th, 2005, 02:53
Highly Reputable Member
Join Date: May 2005
Location: U.K
Age: 21
Posts: 739
Thanks: 0
Thanked 0 Times in 0 Posts
html cdonts from access

hi

im fairly new to asp and am trying and sort of succeeding in picking it up. however i keep having problems along the way, as you do when learning new languages.

anyway, i am wanting to open a db and send a html email using cdonts.

what i am wanting tho is for the email to contain info from the database

like welcome [name of person in db]

now as far as my asp knowledge goes is adding a new record and displaying all the records in a page.

can anybody show me how to open the db and use the values to send the email with relevent data in.
thanks alot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old May 27th, 2005, 07:43
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
this is some really old code i dug out, it does the job....

Code: Select all
<%
Dim strConn
strConn = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("emails.mdb") & ";"

Const adUseClient = 3
Const adOpenKeyset = 1
Const adLockReadOnly = 1

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.open strConn

Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.CursorLocation = adUseClient
objRS.CursorType = adOpenKeySet
objRS.LockType = adLockReadOnly
strQuery = "SELECT [Name], [EmailAddress] FROM [tblEmails]"

objRS.open strQuery, objConn, , , adCmdText

If objRS.RecordCount = 0 Then
%>
no emails on list
<%
Else
 Do while Not objRS.EOF

strMessage ="<html>"& VbCrlf
strMessage = strMessage &"<body>"& VbCrlf
strMessage = strMessage &"Dear "& objRS("Name") VbCrlf
strMessage = strMessage &"</body>"& VbCrlf
strMessage = strMessage &"</html>"& VbCrlf

Set obCDOMail = Server.CreateObject("CDONTS.NewMail")
obCDOMail.BodyFormat = 0
obCDOMail.MailFormat = 0
obCDOMail.Importance = 1
		
obCDOMail.From = "sender name<sender-email>"
obCDOMail.Value("Reply-To") = "sender-email"
obCDOMail.To = Trim(objRS("Email"))
obCDOMail.Subject = "subject"
obCDOMail.Body = strMessage
obCDOMail.Send
Set obCDOMail = Nothing
strMessage = ""
		
objRS.MoveNext
Loop
End If
Response.Write "

Sent " & objRS.RecordCount & " Emails."

objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing
%>
hope that helps
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old May 27th, 2005, 15:20
Highly Reputable Member
Join Date: May 2005
Location: U.K
Age: 21
Posts: 739
Thanks: 0
Thanked 0 Times in 0 Posts
hi

cheers for tht but i may have explained it wrong. i thought that html was structured the same...im not sure what you gave me does. u see i used microsofts example of how to do html cdonts. this is the script from the page.

Code: Select all
<% 
 dim Connect, Classifieds
Set Connect = Server.CreateObject("ADODB.Connection")
 connections
Set Classifieds = Server.CreateObject("ADODB.Recordset")
Classifieds.Open "SELECT * FROM profile", Connect, 2, 2 
Classifieds.AddNew 
if filename > "" then
Classifieds("image") = TargetURL
else
Classifieds("image") =  "/"&folder&"/blank.gif"
end if
Classifieds("name") = name
Classifieds("posted") = DATE
Classifieds("username") = username
Classifieds("email") = email
Classifieds("password") = password 
Classifieds("question") = question
Classifieds("answer") = answer
Classifieds.Update
Classifieds.close
set Connect = nothing



dim Mail
    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 & "</head>"
    HTML = HTML & "<body bgcolor=""FFFFFF"">"
    HTML = HTML & "welcome message....[/b]</p>"
    HTML = HTML & "

<font size =""2"" face=""Tahoma"">"
    HTML = HTML & "Dear , Thankyou for signing up 
Your account details are as follows:
"
    HTML = HTML & "Username: 
"
    HTML = HTML & "Password: 
"
    HTML = HTML & "Secret question: 
"
    HTML = HTML & "Answer: 
"
    HTML = HTML & "</body>"
    HTML = HTML & "</html>"

    myMail.From="someone@microsoft.com"
    myMail.To="g@msn.com"
    myMail.Subject="Sample CDONTS HTML Message"
    myMail.BodyFormat=0
    myMail.MailFormat=0
    myMail.Body=HTML
    myMail.Send
    set mymail=nothing
    Response.Write "Message Sent!"
For example what im wanting the script to do is on line 38 id like the name to be displayed in the email with other account info (lines 39-42). and in the TO part of the script line 47 id like the email field in tere. hope tht makes sense.
thanks for the reply smokie - much appriciated
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old May 31st, 2005, 09:20
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
Hi ben, post the code you wanna use and i'll fill in the gaps for you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old May 31st, 2005, 15:36
Highly Reputable Member
Join Date: May 2005
Location: U.K
Age: 21
Posts: 739
Thanks: 0
Thanked 0 Times in 0 Posts
hey

cheers smokie but i got a good asp tutorial and anaged to do it. just was a case of using

& Classifieds.Fields("wheatever").Value & in the lines inside the thml email. you see i did not use the &'s which was the problem.

cheers for the replys!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Jun 14th, 2005, 20:34
Highly Reputable Member
Join Date: May 2005
Location: U.K
Age: 21
Posts: 739
Thanks: 0
Thanked 0 Times in 0 Posts
i thought id add this on the same topic as it a differnt problem with the same script.

ive changed how i use the email now, and its done from a form. im using a form instead of a db to add fields to the script but it wont send. its fine when i place my email address in the 'to' like above.

Code: Select all
myMail.From="administrator@*.com"
    myMail.To=request.form("mailto")
    myMail.Subject=request.form("subject")
    myMail.BodyFormat=0
    myMail.MailFormat=0
    myMail.Body=HTML
    myMail.Send
    set mymail=nothing
    Response.Write "Message Sent!"
    %>
this is the code, the subject line works, not the to one, yet they are both the same.
im stumped

thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Jun 14th, 2005, 22:45
Highly Reputable Member
Join Date: May 2005
Location: U.K
Age: 21
Posts: 739
Thanks: 0
Thanked 0 Times in 0 Posts
nm people i spotted error in the page before that was passing a username instead of an email

good thing i posted under this thread then !!!!


cheers
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
html, cdonts, access

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 On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to connect the microsoft access database using HTML page mazenbluee Databases 5 Nov 21st, 2007 06:49
Access into HTML JTWork Web Page Design 3 Feb 7th, 2007 07:05
Cdonts air duster Classic ASP 5 Dec 21st, 2005 13:19
Access a HTML InputBox through the Code-Page bwalker ASP.NET Forum 5 Nov 10th, 2005 12:58
CDONTS Email ekendricks Classic ASP 2 Jan 29th, 2004 08:54


All times are GMT. The time now is 09:56.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

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