Access 2000 - Email all records from subform

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

Guest

I have a subform which houses email addresses.

I created a command button on the main form to generate an individual email
for each of the recipients on the subform.

My problem is that it only creates the email for the 1st record on the
subform (the selected record).

I would like some code that will either generate an email for all.

The code i have is as follows:

If Administrator <> [R/M] Then
DoCmd.SendObject _
, _
, _
, _
Forms!IssueInfo!EmailRecipients.Form!EmailAddress, _
, _
, _
"My email message here", _
False
 
I have a subform which houses email addresses.

I created a command button on the main form to generate an individual email
for each of the recipients on the subform.

My problem is that it only creates the email for the 1st record on the
subform (the selected record).

I would like some code that will either generate an email for all.

The code i have is as follows:

If Administrator <> [R/M] Then
DoCmd.SendObject _
, _
, _
, _
Forms!IssueInfo!EmailRecipients.Form!EmailAddress, _
, _
, _
"My email message here", _
False

You have to create a recordset clone of the subform's records and then
process them... This should get you started....

Private Sub cmdSendEMails_Click()
Dim rs As DAO.Recordset
Dim strEMails As String

Set rs = Me!sfrmOrphan.Form.RecordsetClone

'---Create/instantiate your Outlook/CDOSys objects here...
rs.MoveFirst

Do Until rs.EOF
'---put your e-mail code here (the Outlook automation).
'----'something like this...
olkMsg.Recipients.Add(rs.Fields("EMailAddress"))
olkMsg.Body="My Message"
olkMsg.Send

rs.MoveNext
Loop

rs.Close
Set rs = Nothing

End Sub
 
Back
Top