[AccessD] Error Sending Emails Through Exchange

Stuart McLachlan stuart.mclachlan at gmail.com
Mon Mar 17 17:11:11 CDT 2014


I don't use CDO ( I role my own email code), but I'd strongly suspect this line:

                .Item(cdoSMTPAuthenticate) = cdoAnonymous

You will need an authenticated connection to the Exchange server before it will accept email 
for an outside address.



On 18 Mar 2014 at 9:53, David Emerson wrote:

> 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
> 
> 
> 
> 
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 




More information about the AccessD mailing list