Aircorp31
asked on
Error 2295: Unknown message Recipients
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.
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sorry, i didn't notice the semicolon
ASKER
Basically in the docmd.sendobject line in the CC: area I am adding 2 strings together and trying to separate them with a semicolon and when I have the injury and damage checkboxes checked it works fine but when I have nothing checked it gives me that error.
I know the error is with the semicolon now, so how do I add the two strings together with a semicolon in the same CC: field.