Use sendobject to email multiple addresses

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear All

thanks in advance for any help that I will recieve, I am using sendobject to
send an email , but I would like to have more that one email address taken
from the query how would I concatenate the records together, the query that I
would get the email address from is called emailReports and the address field
is imaginatively email.

I would really appreciate some help,

thanks

Phil
 
Phil said:
Dear All

thanks in advance for any help that I will recieve, I am using
sendobject to send an email , but I would like to have more that one
email address taken from the query how would I concatenate the
records together, the query that I would get the email address from
is called emailReports and the address field is imaginatively email.

I would really appreciate some help,

Open a Recordset on the query, loop through all records while appending the
Email address field into a string variable separated by semi-colons, then use
the variable for the argument in SendObject after the loop completes.
 
Hi Rick

thanks for your reply, any chance of sample code that I could modify or a
link of where to find some. sorry about this my VBA skills leave a lot to be
desired, I will look in the forums in the meantime reagarding your reply

thanks again


Phil
 
emailReports

Dim rs as dao.recordset
Dim sAddress as string
set rs = currentdb.openrecordset("select email from emailReports")
rs.movelast
saddress = Join(rs.GetRows(rs.Recordcount), ";")
msgbox saddress

Krgrds,
Perry
 
Hi Perry

I have used:

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sAddress As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("select from [Emailteacher]")
rs.MoveLast
sAddress = Join(rs.GetRows(rs.RecordCount), ";")
MsgBox sAddress


the report name I gave was wrong sorry I get an error that states:

run time 3061 too few parameters expected 1. I have tried looking at other
examples and cannot find where the problem is any ideas

Phil
 
If y're sure the field is part of the Emailteacher table, then
try following:

Replace[QUOTE]
Set rs = db.OpenRecordset("select [email] from [Emailteacher]")[/QUOTE]
by
Set rs = db.OpenRecordset("select [Emailteacher].[email] from
[Emailteacher]")

Kindly repost, if this doesn't remedy

Krgrds,
Perry



[QUOTE="Phil"]
Hi Perry

I have used:

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sAddress As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("select [email] from [Emailteacher]")
rs.MoveLast
sAddress = Join(rs.GetRows(rs.RecordCount), ";")
MsgBox sAddress


the report name I gave was wrong sorry I get an error that states:

run time 3061 too few parameters expected 1. I have tried looking at other
examples and cannot find where the problem is any ideas

Phil

[QUOTE="Perry"]
emailReports

Dim rs as dao.recordset
Dim sAddress as string
set rs = currentdb.openrecordset("select email from emailReports")
rs.movelast
saddress = Join(rs.GetRows(rs.Recordcount), ";")
msgbox saddress

Krgrds,
Perry
[/QUOTE][/QUOTE]
 
Hi Perry

thanks for your help it has got me going in the correct direction, I think
my problem is I did not tell you the full story, the query is based on a
parameter on a form and i think the problem is that access cannot resolve
the parameter value this way, I have come up with some code for this , and
have started a new post with code that i have pieced together, although it is
still not working,

this is what I have ended up with

im rst As DAO.Recordset
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strEmail As String

Set db = CurrentDb()
Set qdf = db.QueryDefs("Emailteacher")
qdf.Parameters![EventID] = Forms![Events1]![EventID]
Set rst = qdf.OpenRecordset

With rst
If (Not .BOF) And (Not .EOF) Then
.MoveFirst
strEmail = .Fields("email")
.MoveNext
End If

If (Not .BOF) And (Not .EOF) Then
Do Until .EOF
strEmail = strEmail & ", " & .Fields("email")
.MoveNext
Loop
End If
.Close
End With

but get error item not found in this collection, I am sure it is somthing
simple

thanks again

Phil

Perry said:
If y're sure the field (e-mail address removed)
 
Replace
qdf.Parameters![EventID] = Forms![Events1]![EventID]
by
Dim sParam as string
sparam = nz(Forms![Events1]![EventID], "")
qdf.Parameters![EventID] = sParam

Krgrds,
Perry

Phil said:
Hi Perry

thanks for your help it has got me going in the correct direction, I think
my problem is I did not tell you the full story, the query is based on a
parameter on a form and i think the problem is that access cannot resolve
the parameter value this way, I have come up with some code for this , and
have started a new post with code that i have pieced together, although it
is
still not working,

this is what I have ended up with

im rst As DAO.Recordset
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strEmail As String

Set db = CurrentDb()
Set qdf = db.QueryDefs("Emailteacher")
qdf.Parameters![EventID] = Forms![Events1]![EventID]
Set rst = qdf.OpenRecordset

With rst
If (Not .BOF) And (Not .EOF) Then
.MoveFirst
strEmail = .Fields("email")
.MoveNext
End If

If (Not .BOF) And (Not .EOF) Then
Do Until .EOF
strEmail = strEmail & ", " & .Fields("email")
.MoveNext
Loop
End If
.Close
End With

but get error item not found in this collection, I am sure it is somthing
simple

thanks again

Phil

Perry said:
If y're sure the field (e-mail address removed)
 
thanks again, everytime I fix one error I get another, I will thanks again

Phil

Perry said:
Replace
qdf.Parameters![EventID] = Forms![Events1]![EventID]
by
Dim sParam as string
sparam = nz(Forms![Events1]![EventID], "")
qdf.Parameters![EventID] = sParam

Krgrds,
Perry

Phil said:
Hi Perry

thanks for your help it has got me going in the correct direction, I think
my problem is I did not tell you the full story, the query is based on a
parameter on a form and i think the problem is that access cannot resolve
the parameter value this way, I have come up with some code for this , and
have started a new post with code that i have pieced together, although it
is
still not working,

this is what I have ended up with

im rst As DAO.Recordset
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strEmail As String

Set db = CurrentDb()
Set qdf = db.QueryDefs("Emailteacher")
qdf.Parameters![EventID] = Forms![Events1]![EventID]
Set rst = qdf.OpenRecordset

With rst
If (Not .BOF) And (Not .EOF) Then
.MoveFirst
strEmail = .Fields("email")
.MoveNext
End If

If (Not .BOF) And (Not .EOF) Then
Do Until .EOF
strEmail = strEmail & ", " & .Fields("email")
.MoveNext
Loop
End If
.Close
End With

but get error item not found in this collection, I am sure it is somthing
simple

thanks again

Phil

Perry said:
If y're sure the field (e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top