[AccessD] Error Sending Emails Through Exchange

David Emerson newsgrps at dalyn.co.nz
Mon Mar 17 20:20:28 CDT 2014


I thought as much Stuart but not sure what I should use.

I have the following in the code below which I tried:

 '                .Item(cdoSMTPAuthenticate) = cdoBasic
 '                .Item(cdoSendUserName) = "username"
 '                .Item(cdoSendPassword) = "password"

I used the Windows username and password but I suspect that it should have
been the Exchange credentials.  Can anyone clear this up for me before I go
back to the client and do some testing?

Regards

David

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan
Sent: Tuesday, 18 March 2014 11:11 a.m.
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Error Sending Emails Through Exchange

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




More information about the AccessD mailing list