Happy New Year to ALL!
I am trying to e-mail from a form that displays filtered result, but having trouble. Could someone please guide me?
I am using DoCmd.SendObject (a routine that I found in a newsgroup). This routine works fine when I am sending it to all the recipients, but not to filtered recipients. The form shows filtered result, but I am not being able to use the command to only send to filtered recipients. Following is the code:
Private Sub cmdGenerateList_Click()
'Create Email list from the appropriate query and open Outlook with those addresses in the cc: field
Dim db As Database, rs As Recordset, sql As String, emailTo As String, txtEmailList As String
On Error GoTo Err_cmdGenerateList_Click
Set db = CurrentDb()
emailTo = ""
sql = "select EmailName from qInd_info "
Set rs = db.OpenRecordset(sql)
Do Until rs.EOF
If Not IsNull(rs!EmailName) Then
'build up email addresses separated by a semicolon
emailTo = emailTo & rs!EmailName & "; "
End If
rs.MoveNext
Loop
'Remove the last semicolon
If Right(emailTo, 2) = "; " Then
emailTo = Left(emailTo, Len(emailTo) - 2)
End If
' Me.txtEmailList = emailTo
'Create the message with the recipients in the BCC: field
' DoCmd.SendObject acSendNoObject, , , , , emailTo
DoCmd.SendObject acSendNoObject, , , , emailTo
Exit_cmdGenerateList_Click:
Exit Sub
Err_cmdGenerateList_Click:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Description
Resume Exit_cmdGenerateList_Click
End Select
End Sub
I am trying to e-mail from a form that displays filtered result, but having trouble. Could someone please guide me?
I am using DoCmd.SendObject (a routine that I found in a newsgroup). This routine works fine when I am sending it to all the recipients, but not to filtered recipients. The form shows filtered result, but I am not being able to use the command to only send to filtered recipients. Following is the code:
Private Sub cmdGenerateList_Click()
'Create Email list from the appropriate query and open Outlook with those addresses in the cc: field
Dim db As Database, rs As Recordset, sql As String, emailTo As String, txtEmailList As String
On Error GoTo Err_cmdGenerateList_Click
Set db = CurrentDb()
emailTo = ""
sql = "select EmailName from qInd_info "
Set rs = db.OpenRecordset(sql)
Do Until rs.EOF
If Not IsNull(rs!EmailName) Then
'build up email addresses separated by a semicolon
emailTo = emailTo & rs!EmailName & "; "
End If
rs.MoveNext
Loop
'Remove the last semicolon
If Right(emailTo, 2) = "; " Then
emailTo = Left(emailTo, Len(emailTo) - 2)
End If
' Me.txtEmailList = emailTo
'Create the message with the recipients in the BCC: field
' DoCmd.SendObject acSendNoObject, , , , , emailTo
DoCmd.SendObject acSendNoObject, , , , emailTo
Exit_cmdGenerateList_Click:
Exit Sub
Err_cmdGenerateList_Click:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox Err.Description
Resume Exit_cmdGenerateList_Click
End Select
End Sub