sendobject, emal bcc recipients from field

F

FrankieNap

Hello all,
I am not a programmer, although I have been picking things up
along the way, so if any of my explanations sound rudimentary I
apologize in advance.

I have designed a database to keep track of my students, each
student record includes things like a Student ID (primary key),
firstname, lastname, email address, and various other contact
information. I want to be able to have a control on my form which
allows me to email my students with the click of a button. I am using
the SendObject function to open a new email, I then select
acSendNoObject. What I want to be able to do is automatically fill in
the bcc field (not the "to" field since I do not want my students
having every other person's email) with information from my table of
students. Their emails are stored in the field "Email-Student". I
also would like to restrict the recordset based on the value of
another field "Emailer" which either has the value "All", "Active", or
"Inactive" in order to be able to email all of my students (former and
current), my current students only, or only the students I have had in
the past. I figure that I would have to use an If,ElseIf function to
get this done.
The biggest problem I have is inserting the email addresses of my
students into the bcc field. I have searched online and have yet to
be able to figure it out. Below is a portion of the code I have
written (not very much, I know). Any information would be greatly
appreciated. Thank you.


If Me.Emailer = "Active" Then
DoCmd.SendObject acSendNoObject
 
J

Jeff L

Your syntax would be DoCmd.SendObject acSendNoObject, , , , ,
YourEmailAddresses. Hope that helps!
 
F

FrankieNap

Your syntax would be DoCmd.SendObject acSendNoObject, , , , ,
YourEmailAddresses. Hope that helps!

but how do i get the email addresses from a field added to the bcc so
that i do not have to type them in manually?
 
J

Jeff L

but how do i get the email addresses from a field added to the bcc so
that i do not have to type them in manually?

You would need to write some code that would loop through your
addresses and add them to the BCC field. Something like this:

Dim Recipients as String, qry as string, rst as object

qry = "Select Email from YourDataSourceHere where Emailer = 'Active'
Set rst = currentdb.OpenRecordset(Qry)
rst.movefirst
Do While rst.eof = False
If IsNull(Recipients) then
Recipients = rst!Email
Else
Recipients = Recipients & ";" & rst!Email
End If
rst.MoveNext
Loop

DoCmd.SendObject acSendNoObject, , , , , Recipients


You will need to tweak this so that you use your field names and table/
query name, but that should at least point you in the right direction.
 

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

Similar Threads


Top