Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jmail from recordset

Status
Not open for further replies.

schase

Technical User
Sep 7, 2001
1,756
0
0
US
Trying to send email to users in a database - based off of their pilot_level (user level) that can be picked from a database.

I get the form results to transfer a-ok to a confirmation type page. but get lost at that point. I use UltraDev4, so a bit lost on hand coding still. Heres what I have

Thank you in advance

<%
'function to open database
dim sql,con, gvfforce
set con=server.createObject(&quot;ADODB.Connection&quot;)
set gvfforce = Server.CreateObject(&quot;ADODB.Recordset&quot;)
con.open connectionString
SQL = &quot;Select Email from tblPilots ORDER BY Pilot_Level&quot;
con.execute sql
set gvfforce = nothing
set con = nothing



Dim emStr
emStr = &quot;&quot;

WHILE not gvfforce.eof and response.isclientconnected()
emStr = emStr & con(&quot;Email&quot;) & &quot;;&quot;
con.movenext
WEND
con.close
set con = nothing

'function to close database

con.Close()


Dim objMail
Set objMail = Server.CreateObject(&quot;JMail.SMTPMail&quot;)
objMail.ServerAddress = &quot;smtp.stormhosts.com&quot;

objMail.From = &quot;webmaster@flydetour.com&quot;
objMail.Subject = strSubject
objMail.To = &quot;pilots@flydetour.com&quot;
objMail.BCC = emStr
objMail.Body = strMessage
objMail.Send
Response.write(&quot;Mail was Sent&quot;)
set objMail = nothing
%>
 
you just need to run through all entries in the database and send the the email each time. if you are sending by user level then you need to check if the pilot is of a certain level and send accordingly.

i hope im not being to confusing



while not yourRecordSet.eof do
strEmail = yourRecordSet(&quot;email&quot;)

if yourRecordSet(&quot;pilot_level&quot;) = &quot;something&quot; then

' Create the JMail message object
set msg = server.createOBject( &quot;JMail.message&quot; )

' your details
msg.From = &quot;you@you.com&quot;
msg.FromName = &quot;your company&quot;

' pilots e-mail address
msg.addRecipient strEmail

' the subject
msg.subject = &quot;your subject&quot;

' the body
msg.body = &quot;your message&quot;

' send the message or show error
if not msg.send(&quot;your server&quot; ) then
response.write &quot;error&quot;
end if

else

your altenative message

end if


rs.moveNext
wend
 
hmmm lemme give that a shot, I know what your talking about and it's pretty much what I'm trying. I had found code for a cdonts set - but i'm jmail only on this server.

 
trying it, and for a bit it just acted like it emailed, but nothing. heres what I got.

<%

Dim strFrom
Dim strSubject
Dim strMessage


strSubject = Request.Form(&quot;fldSubject&quot;)
strMessage = Request.Form(&quot;fldMessage&quot;)
strFrom = Request.Form(&quot;fldFrom&quot;)
%>
<%
Dim Jmail
Dim oRS, sDSN, sBody, sSubject, iPriority, sTo

Set JMail = Server.CreateObject(&quot;JMail.SMTPMail&quot;)

JMail.ServerAddress = &quot;smtp.stormhosts.com&quot;
JMail.ContentType = &quot;text/html&quot;
JMail.Sender = &quot;Webmaster@flydetour.com&quot;

sSubject = strSubject
sBody = strMessage
'iPriority = request(&quot;fldImportance&quot;)

Set oRS = server.CreateObject(&quot;adodb.recordset&quot;)


sDSN = &quot;DSN=gvfforce;&quot;


oRS.Open &quot;SELECT * FROM tblPilots WHERE pilot_level = strRecipient&quot;, sDSN
Do While Not oRS.EOF
sTo = oRS (&quot;Email&quot;)

SendMail sSubject, sBody, sTo,iPriority
oRS.MoveNext
Loop


oRS.Close
Set oRS = nothing
Set Jmail = nothing
On Error Resume Next
If Err <> 0 Then
Response.Write &quot;An error occurred. <br>&quot;
Response.Write &quot;Error: &quot; & err.number & &quot;<br>&quot;
Response.Write &quot;Error: &quot; & err.description & &quot;<br>&quot;
End If
Response.Redirect &quot;sendemail.asp&quot;
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top