troubleshooting Question

Error 2295: Unknown message Recipients

Avatar of Aircorp31
Aircorp31Flag for United States of America asked on
Microsoft Access
4 Comments1 Solution1587 ViewsLast Modified:
I was going through final checks  of my program and it appears as if something is conflicting in my code and I do not know what it is.

I added my code and you can see I created 2 new strings to deal with 2 additional boxes called injury and damage boxes.  They work the same way so if there is an injury someone checks the box and it is enabled.  Then they type something in and it sends it to a certain set of emails.  I did the same thing with the damage box.  That works all fine and dandy, however if you do not check either injury or damage and just choose to send it it gives me this error.

There was an error executing the command.
Error2295:
Unknown message recipient(s); the message was not sent.

I am thinking this is happening because it is looking for something in the CC: field and it doesnt have anything because those boxes are not checked.  How do I fix this issue.  If it is a separate question let me know and I will post it in another post but it is related to the code you initially gave me.


Private Sub cmdSendEmail_Click()
On Error GoTo Err_cmdSendEmail_Click
 
'Declare the variables
Dim strFormFields   As String
Dim strEmails       As String
Dim strESHEmails    As String
Dim strDMGEmails    As String
Dim ctl             As Control
    
'Set the Public Variable that stores the CurrentEventID
lngpubEventID = Me.EventID
   
    'Set the email address to the hidden Label's Caption
    strEmails = Me.lblEmail.Caption
    
    'If there is an Injury text then add the "ESH" persons email address
    If Len(Me.Injury_Text) > 0 Then
        strESHEmails = DLookup("Email", "tblESH", "SystemID=8")
        
    End If
        
        'If there is an Injury text then add the "DMG" persons email address
    If Len(Me.Damage_Text) > 0 Then
        strDMGEmails = DLookup("Email", "tblDMG", "SystemID=9")
    End If
    
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    
    'Send the email with a report
    DoCmd.SendObject acSendReport, "Report by Incident", , strEmails, strESHEmails & ";" & strDMGEmails,, Me.Topic, "Incident ID" & ":" & vbTab & Me.EventID & vbCrLf & "Date/Time" & ":" & vbTab & Me.Date_Time & vbCrLf & "Facility" & ":" & vbTab & Me.Facility.Column(1) & vbCrLf & "System" & ":" & vbTab & Me.System.Column(1) & vbCrLf & "Subsystem" & ":" & vbTab & Me.Subsystem & vbCrLf & "Employee" & ":" & vbTab & Me.Employee & vbCrLf & "Work Order #" & ":" & vbTab & Me.Work_Order__ & vbCrLf & "Summary" & ":" & vbTab & Me.Summary & vbCrLf & "Suspected Cause" & ":" & vbTab & Me.Suspected_Cause & vbCrLf & "Injury" & ":" & vbTab & Me.Injury_Text & vbCrLf & "Damage" & ":" & vbTab & Me.Damage_Text & vbCrLf & "Personnel Involved" & ":" & vbTab & Me.Personnel_Involved & vbCrLf & "Verbal Notifications" & ":" & vbTab & Me.Verbal_Notifications & vbCrLf & "A report is attached to this email for your printing convenience." & vbCrLf, True
    
Exit_cmdSendEmail_Click:
    Exit Sub
    
Err_cmdSendEmail_Click:
    'If the user closes the Email screen without sending
    If Err.Number = 2501 Then
        Resume Exit_cmdSendEmail_Click
    Else
        MsgBox "There was an error executing the command." & vbCrLf & "Error" & Err.Number & ":" & vbCrLf & Error, vbExclamation
        Resume Exit_cmdSendEmail_Click
        End If
        
         'Reset the EventID Variable
    lngpubEventID = 0
    
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros