[AccessD] Error Sending Emails Through Exchange

David Emerson newsgrps at dalyn.co.nz
Mon Mar 17 15:53:50 CDT 2014


Hi Listers,

 

Below is the error message my Access database is getting when I try to send
out an email using cdosys.dll:

 

Error Number : -2147220977

Error Msg: The server rejected one or more recipient addresses.  The server
response was: 550 5.7.1 Unable to relay.

 

The VBA code I am using is below:

 

    Dim msg As Message, strSMTPServer As String, intSMTPConnectionTimeout As
Integer, intSMTPServerPort As Integer

    Dim strOrganisation As String, strFrom As String, strSubject As String,
strBody As String, strHeader As String

 

    strSMTPServer = DLookup("EmailSMTPServer", "tlkpVariable", "VariableID =
1")

    intSMTPConnectionTimeout = DLookup("EmailSMTPConnectionTimeout",
"tlkpVariable", "VariableID = 1")

    intSMTPServerPort = DLookup("EmailSMTPServerPort", "tlkpVariable",
"VariableID = 1")

    strOrganisation = DLookup("EmailOrganisation", "tlkpVariable",
"VariableID = 1")

    strFrom = DLookup("EmailSender", "tlkpVariable", "VariableID = 1")

    strSubject = DLookup("EmailSubject", "tlkpVariable", "VariableID = 1")

    strBody = DLookup("EmailBody", "tlkpVariable", "VariableID = 1")

 

        Set msg = CreateObject("CDO.Message")

        With msg

            With .Configuration.Fields

                .Item(cdoSMTPAuthenticate) = cdoAnonymous

'                .Item(cdoSMTPAuthenticate) = cdoBasic

'                .Item(cdoSendUserName) = "username"

'                .Item(cdoSendPassword) = "password"

                .Item(cdoSendUsingMethod) = cdoSendUsingPort

                .Item(cdoSMTPServer) = strSMTPServer

                .Item(cdoSMTPConnectionTimeout) = intSMTPConnectionTimeout

                .Item(cdoSMTPServerPort) = intSMTPServerPort

                .Update

            End With

            .Organization = strOrganisation

            .To = strTo

            .Subject = Nz(strSubject, " ")

            .TextBody = Nz(strBody, " ")

            .From = strFrom

            .Send

        End With

        Set msg = Nothing

   

 

The lines in red above have also been tried using the users windows logon
and password but the same message appeared (not sure if this was the correct
data for these properties though).

 

The code has worked fine for other clients but they have not used Microsoft
Exchange for their emails.

It also works if the recipient address has the same domain as the server.

 

Any help would be appreciated.

 

Regards

David Emerson
Dalyn Software Ltd
Wellington, New Zealand

 

 



More information about the AccessD mailing list