mandrake06
Technical User
Hi guys. I'm extremely new at this, so sorry if I don't provide enough information - if there's anything you need, I'll try my best to answer. Sorry about my english!
I have two tables, "Students" and "Courses", linked together by a "Course Details" table forming a many-to-many relationship. In the "Courses" form I've set up a continuous subform ("Sub StudentsFCourses") that lists all the students that participated in each one of the Courses (it looks pretty weird when I type it but I hope it makes sense).
I've managed to set up some code that lets me e-mail, one at a time, each one of the students in that subform via a command button, using Outlook:
================================
Private Sub CmdMail_Click()
On Error Resume Next
Dim stWhere As String '-- Criteria for DLookup
Dim varTo As Variant '-- Address for SendObject
Dim stText As String '-- E-mail text
Dim stSubject As String '-- Subject line of e-mail
Dim stWho As String '-- Reference to Students table
Dim strSQL As String '-- Create SQL update statement
Dim errLoop As Error
'-- Combo of names to assign ticket to
stWho = Me.StudentName
stWhere = "Students.StudentName = " & "'" & stWho & "'"
'-- Looks up email address from Students table
varTo = DLookup("[StudentEMail]", "Students", stWhere)
stSubject = ""
stText = ""
'Write the e-mail content for sending to assignee
DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1
Exit_CmdMail_Click:
Exit Sub
End Sub
=============================
Obs: I don't need to fill out the subject line, e-mail text or attachments as those will change pretty frequently.
What I'd like to do is place another command button in the "Courses" form that will allow me to send just one e-mail with its "BCC" field filled out with all the e-mails from the students in the subform, and the "To:" field containing my own e-mail address (always constant) so that I get a copy of it.
Is that possible? I've read the wonderful threads in the FAQ related to sending e-mails via Access but I could not find any way to do the above specifically. Maybe I missed something? Any help from you guys would be really welcome!
I have two tables, "Students" and "Courses", linked together by a "Course Details" table forming a many-to-many relationship. In the "Courses" form I've set up a continuous subform ("Sub StudentsFCourses") that lists all the students that participated in each one of the Courses (it looks pretty weird when I type it but I hope it makes sense).
I've managed to set up some code that lets me e-mail, one at a time, each one of the students in that subform via a command button, using Outlook:
================================
Private Sub CmdMail_Click()
On Error Resume Next
Dim stWhere As String '-- Criteria for DLookup
Dim varTo As Variant '-- Address for SendObject
Dim stText As String '-- E-mail text
Dim stSubject As String '-- Subject line of e-mail
Dim stWho As String '-- Reference to Students table
Dim strSQL As String '-- Create SQL update statement
Dim errLoop As Error
'-- Combo of names to assign ticket to
stWho = Me.StudentName
stWhere = "Students.StudentName = " & "'" & stWho & "'"
'-- Looks up email address from Students table
varTo = DLookup("[StudentEMail]", "Students", stWhere)
stSubject = ""
stText = ""
'Write the e-mail content for sending to assignee
DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1
Exit_CmdMail_Click:
Exit Sub
End Sub
=============================
Obs: I don't need to fill out the subject line, e-mail text or attachments as those will change pretty frequently.
What I'd like to do is place another command button in the "Courses" form that will allow me to send just one e-mail with its "BCC" field filled out with all the e-mails from the students in the subform, and the "To:" field containing my own e-mail address (always constant) so that I get a copy of it.
Is that possible? I've read the wonderful threads in the FAQ related to sending e-mails via Access but I could not find any way to do the above specifically. Maybe I missed something? Any help from you guys would be really welcome!