This is a discussion on "CDOSYS Mail" within the Classic ASP section. This forum, and the thread "CDOSYS Mail are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
CDOSYS Mail
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
CDOSYS Mail
Hi
Was wondering if anybody could help me with this. I am trying to create a page that sends out an email based upon records in my database. I can get the script to work fine if I just send one message. However, when I try to get it to repeat and loop through the records I get an error and only one email is sent. Can anybody help? Here is the code Dim Connect, Recordset1 Set Connect = Server.CreateObject("ADODB.Connection") Connect.Open "dsn=StaffDr;uid=mcoker;pwd=mcoker;" Set Recordset1 = Connect.Execute("SELECT * FROM dbo.TestContact") do until Recordset1.eof%><% 'Create the e-mail server object Set objCDOSYSMail = Server.CreateObject("CDO.Message") Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration") 'Outgoing SMTP server objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "myserver" objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 objCDOSYSCon.Fields.Update 'Update the CDOSYS Configuration Set objCDOSYSMail.Configuration = objCDOSYSCon objCDOSYSMail.From = "***@***.com" objCDOSYSMail.To = (Recordset1.Fields.Item("ContactEmail").Value) objCDOSYSMail.Subject = "HR Information Update Request" objCDOSYSMail.HTMLBody = "Please login to check the information that HR currently holds on you </p> username: "&(Recordset1.Fields.Item("Username").Value)&" Password: "&(Recordset1.Fields.Item("Password").Value)&" </p>To view this request please click here http://localhost/blah?blah=1" objCDOSYSMail.Send 'Close the server mail object Set objCDOSYSMail = Nothing Set objCDOSYSCon = Nothing %> <%recordset1.movenext loop %> Any help you can offer would be really appreciated Thanks Marcus |
|
|
|
|||
|
whats the error you recieve?
|
|
|||
|
Re: CDOSYS Mail
Not sure if this will be the answer to your problem or not, but I am doing a similar action using a text file for my database. As a result, I'm not using the ADO connections, but my code works with multiple e-mails by using a loop, maybe it will help, or possibly inspire a different approach to your problem? Here's what I use (clearly this is just the nuts and bolts, and not the complete code, but it should give you an idea.):
set alladdys = fso.OpenTextFile(server.mappath ("emails.txt")) do until (alladdys.AtEndOfStream) addys = alladdys.ReadLine Set objMail = Server.CreateObject("CDONTS.NewMail") objMail.From = from objMail.To = addys objMail.Subject = projectname objMail.BodyFormat = 0 objMail.MailFormat = 0 objMail.Body = MailBody objMail.Send loop Hope that helps! Qixsilver |
![]() |
| Tags |
| cdosys, mail |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Having Problems with cdosys emails | Phil | Classic ASP | 1 | Sep 12th, 2007 17:23 |
| Creating a contact form on homepage with ASP & CDOSYS? | Foobster | Classic ASP | 0 | Aug 14th, 2007 09:01 |
| CDOSYS problem | Ranger | Classic ASP | 8 | Dec 21st, 2005 09:09 |
| visitors name not displayed in mail after filling in mail form | made on earth | PHP Forum | 7 | Nov 16th, 2005 22:43 |
| CDOSYS | AndyP | Hosting & Domains | 2 | Sep 7th, 2005 12:15 |