提问人:ry94080 提问时间:11/17/2023 最后编辑:ry94080 更新时间:11/18/2023 访问量:23
访问 VBA SMTP 现在需要身份验证
Access VBA SMTP now requires Authentication
问:
我有一些SMTP电子邮件工作正常。但现在,我的组织要求我们使用身份验证向外部域发送电子邮件。
我的工作代码如下图所示:
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 = "[email protected]"
.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
我做了一些研究,发现需要添加一些类似于此代码的内容。但我无法让它工作。
我收到此错误:“服务器拒绝了一个或多个收件人地址。服务器响应为:550 5.7.54 SMTP;无法中继未接受域中的收件人”
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myusername"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
知道我应该如何通过 SMTP 进行身份验证吗?
发送带有 SMTP 身份验证的 CDO 电子邮件
答: 暂无答案
评论