Access VBA SMTP now requires Authentication

Criseno, Ryan 0 Reputation points
2023-11-17T18:56:24.3366667+00:00
I had some SMTP emails that were working just fine. But now my organization requires that we use authentication to send out to outside domain emails.

My working code is as seen below:

Sub SendEmail(sTo As String, sSubject As String, Optional sBody As String, Optional sAttachment As String, Optional sBCC As String)On Error GoTo SendEmail_Err
Start:
Set objmessage = CreateObject("CDO.Message")
With objmessage
    .From = "LV_Reports@orgdomain.org"
    .To = sTo
    .BCC = sBCC
    .Subject = sSubject
    .HTMLBody = sBody
    If sAttachment <> "" Then
        .AddAttachment sAttachment
    End If
    .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.orgserver.org"
    .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Configuration.Fields.Update
    .Send
End With
Exit Sub
SendEmail_Err:
'MsgBox Err.Number & " is the error code for this event. " & Err.Description

    LogError Err.Number, Err.Description & " - " & sAttachment, "SendEmail", , False

Debug.Print
End Sub

I only get an error when sending to external emails
"I get this error: "The server rejected one or more recipient addresses. The server response was: 550 5.7.54 SMTP; Unable to relay recipient in non-accepted domain"

I had some SMTP emails that were working just fine. But now my organization requires that we use authentication to send out to outside domain emails.
My working code is as seen below:

I did some research and found that something along the lines of this code needs to be added. But I still continue to get error.

Any ideas how I'm supposed to authenticate via SMTP?
Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
891 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.