Error 2295

robultra17
robultra17 used Ask the Experts™
on
HI and thanks in advance for anyhelp.

Would anybody be able to look at the code below and see what the problem is. I haven't wrote the code, but am unable to speak to the person that did.

Any help would be appricated.

Thanks

Rob
Private Sub cmdSend_Click()
    Dim szEmailCc As String
    Dim szEmailBCC As String
    Dim szCriteria As String
    Dim szMsgSubject As String
    Dim dbs As Database
    Dim rstEmailAddr As Recordset
    Dim boolEditMsg As Boolean
    
    
    If IsNull(cmbLocation.Value) Then
        MsgBox "please enter Location"
        Exit Sub
    End If
    
    If IsNull(cmbInstrType.Value) Then
        MsgBox "please enter Instrument Type"
        Exit Sub
    End If
    
    boolEditMsg = True
    
    szEmailCc = "My email address"
 
    Set dbs = CurrentDb()
    Set rstEmailAddr = dbs.OpenRecordset("qryGlobalInstrEmail", dbOpenDynaset)
    
    szCriteria = "[pkLocID] = " & cmbLocation.Value & " AND [pkInstrTypeID] = " & cmbInstrType.Value
    
    'Can't use pass parameters from form to query otherwise get 'too few paremeters' error - http://www.access-programmers.co.uk/forums/showthread.php?t=45940
    
    rstEmailAddr.MoveLast
    rstEmailAddr.MoveFirst
    rstEmailAddr.FindFirst szCriteria
    szEmailBCC = ""
    If rstEmailAddr.NoMatch = False Then ' 27/08/2003 CJB Added to print location prompt after finisfing child transacations
        szMsgSubject = rstEmailAddr![txtDescription]
        While (Not (rstEmailAddr.NoMatch))
            szEmailBCC = szEmailBCC + rstEmailAddr![E-mail] + ", "
            rstEmailAddr.FindNext szCriteria
        Wend
            
        MsgBox szEmailBCC
        MsgBox szMsgSubject
        
        DoCmd.SendObject acSendNoObject, , , , szEmailCc, szEmailBCC, szMsgSubject, , boolEditMsg
 
        
        
        
    Else
        MsgBox "There are no users to email"
    End If
 
 
   rstEmailAddr.Close
   dbs.Close
End Sub
 
 
   ' Find current instrument number in In bucket

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
The error code can be turned into words with this command issued in the imediate window...

? accesserror(2295)
Unknown message recipient(s); the message was not sent.@@@1@@1

So it does not like one or more email addresses. I see two problems in the code: the first is in line 23

szEmailCc = "My email address"

szEmailCc is never changed after that, and  "My email address" is certainly not an email address.

There is also a problem in this loop (lines 38-41)...

        While (Not (rstEmailAddr.NoMatch))
            szEmailBCC = szEmailBCC + rstEmailAddr![E-mail] + ", "
            rstEmailAddr.FindNext szCriteria
        Wend

In the bold line a comma is being used to delimit the email addresses, but Outlook (for one email client) uses the Semi-Colon as the delimiter.

Ask him what line highlights when he presses "debug" on the error message.

Author

Commented:
Thanks for the quick response

I changed the email because it was my work email.

It highlights line 46.

Rob

Author

Commented:
Just as you said. I changed the comma should have been a semi-Colon.
Thanks for the quick response.

Rob

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial