Forums

This topic is locked

email multiple recipients from recordset (jmail)

Posted 22 Jan 2003 20:03:39
1
has voted
22 Jan 2003 20:03:39 Dave Clarke posted:
Hi

I know how to set up jmail to send an email, but how do I set it up to email everybody in a recordset?
What I'm trying to do is email everybody who hasn't confirmed their membership after 2 weeks as a sort of reminder.
I have a recordset that contains all uncomfirmed records from the last 2 weeks and now i need to email them all the same email.

Thanks

Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome

Replies

Replied 22 Jan 2003 21:52:42
22 Jan 2003 21:52:42 Dave Clarke replied:
hi again

I've come up with this for the jmail sending page

Comments please.

<%
set rsetReminder = Server.CreateObject("ADODB.Recordset"
rsetReminder.ActiveConnection = MM_connmessages2_STRING
rsetReminder.Source = "SELECT * FROM accessgroups WHERE ((accessgroups.fldjoined<Date()-14)) AND fldGroup = 'Guest' ORDER BY fldjoined DESC"
rsetReminder.CursorType = 0
rsetReminder.CursorLocation = 2
rsetReminder.LockType = 3
rsetReminder.Open()
rsetReminder_numRows = 0
%>
<%
While NOT rsetReminder.EOF
firstname = rsetReminder.Fields.Item("fldFirstname".Value
lastname = rsetReminder.Fields.Item("fldLastname".Value
emailadd = rsetReminder.Fields.Item("fldEmailAddress".Value
username = rsetReminder.Fields.Item("fldusername".Value
password = rsetReminder.Fields.Item("fldPassword".Value
usrid = rsetReminder.Fields.Item("fldnewuserid".Value

crlf=chr(13)+chr(10)
tab=chr(9)
tab2=chr(9)+chr(9)
tab3=chr(9)+chr(9)+chr(9)
tab4=chr(9)+chr(9)+chr(9)+chr(9)

Set JMail = Server.CreateObject("JMail.SMTPMail"
JMail.ClearRecipients
JMail.body = ""
JMail.ServerAddress = "serveraddress"
JMail.Sender = " "
JMail.Subject = "Confirmation Reminder"
JMail.AddRecipient emailadd
JMail.Body = "Hello" & tab & firstname & tab & lastname & crlf & crlf

JMail.appendtext "This is an automated email, please do not reply to it" & crlf & crlf
JMail.appendtext "We notice that you have not yet confirmed your membership." & crlf & crlf
JMail.appendtext "If you wish to remain on our database please " & crlf
JMail.appendtext "Click this link to confirm your membership" & tab2 & "mydomain.co.uk/confirm.asp?" & "usname="&username & "&email="&emailadd &"&passwrd="&password &"&usrid="&usrid & crlf & crlf
Jmail.appendtext "If your mail reader does not allow you to click the link you will have to copy and paste it into your web browsers address bar" & crlf & crlf
JMail.appendtext "Do not forget that you must do this within 7 days or you will be deleted from the database"

JMail.Priority = 1
JMail.Execute
rsetReminder.Movenext
Wend
response.redirect("unconfirmedmemb.asp"
%>
<%
rsetReminder.Close()
%>


ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome

Edited by - Davecl on 23 Jan 2003 21:55:52
Replied 23 Jan 2003 21:56:36
23 Jan 2003 21:56:36 Dave Clarke replied:
hi

Seems to work fine, fingers crossed!

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Replied 25 Jan 2003 17:11:16
25 Jan 2003 17:11:16 Dave Clarke replied:
Huh

I was fooling myself, it doesn't work, keeps coming up with a "not all servers received message" error or something like that.
Am I setting the variables correctly? - firstname = rsetReminder.Fields.Item("fldFirstname".Value
Is the WHILE-WEND correctly positioned?
Please can someone point me in the right direction?

Thanks

Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Replied 25 Jan 2003 19:30:01
25 Jan 2003 19:30:01 Dave Clarke replied:
ok, revised code, this one sends a mail but only to the first record, it doesn't move to the next.

ideas??

<%
set rsetReminder = Server.CreateObject("ADODB.Recordset"
rsetReminder.ActiveConnection = MM_connmessages2_STRING
rsetReminder.Source = "SELECT * FROM accessgroups WHERE ((accessgroups.fldjoined<Date()-50)) ORDER BY fldjoined DESC"
rsetReminder.CursorType = 0
rsetReminder.CursorLocation = 2
rsetReminder.LockType = 3
rsetReminder.Open()
rsetReminder_numRows = 0
%>
<%
If NOT rsetReminder.EOF Then
firstname = rsetReminder.Fields.Item("fldFirstname".Value
lastname = rsetReminder.Fields.Item("fldLastname".Value
emailadd = rsetReminder.Fields.Item("fldEmailAddress".Value
username = rsetReminder.Fields.Item("fldusername".Value
password = rsetReminder.Fields.Item("fldPassword".Value
usrid = rsetReminder.Fields.Item("fldnewuserid".Value

crlf=chr(13)+chr(10)
tab=chr(9)
tab2=chr(9)+chr(9)
tab3=chr(9)+chr(9)+chr(9)
tab4=chr(9)+chr(9)+chr(9)+chr(9)

Set JMail = Server.CreateObject("JMail.SMTPMail"
JMail.ClearRecipients
JMail.body = ""
JMail.ServerAddress = "mailserver"
JMail.Sender = " "
JMail.Subject = "Confirmation Reminder"
JMail.AddRecipient emailadd
JMail.Body = "Hello" & tab & firstname & tab & lastname & crlf & crlf

JMail.appendtext "This is an automated email, please do not reply to it" & crlf & crlf
JMail.appendtext "We notice that you have not yet confirmed your membership." & crlf & crlf
JMail.appendtext "If you wish to remain on our database please " & crlf
JMail.appendtext "Click this link to confirm your membership" & tab2 & "mydomain.co.uk/confirm.asp?" & "usname="&username & "&email="&emailadd &"&passwrd="&password &"&usrid="&usrid & crlf & crlf
Jmail.appendtext "If your mail reader does not allow you to click the link you will have to copy and paste it into your web browsers address bar" & crlf & crlf
JMail.appendtext "Do not forget that you must do this within 7 days or you will be deleted from the database"

JMail.Priority = 1
JMail.Execute
rsetReminder.Movenext
End If
Response.Redirect ("unconfirmed.asp"
%>
<%
rsetReminder.Close()
%>

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome

Edited by - Davecl on 25 Jan 2003 19:33:00
Replied 25 Jan 2003 20:29:11
25 Jan 2003 20:29:11 asp asp replied:
Hey dave, well i havent had to use JMAIL yet, but if you want to save your self some grief, have a look at www.webassist.com they have a UNIVERSAL EMAILER, it will do what you want in 1 minute, i've used this and it has saved me alot of time. they have some online tutorilas so you can see how it works, hope this helps
Replied 26 Jan 2003 08:15:46
26 Jan 2003 08:15:46 Dave Clarke replied:
thanks asp

I'll have a look but I've done it now

I changed the
If NOT rsetRemider.EOF
jmailcode
Then

to

Do Until rsetreminder.EOF
jmailcode
Loop

and i think everything is ok, fingers crossed.

Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome

Reply to this topic