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?