最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vba - Send Email from Access Program - Stack Overflow

programmeradmin1浏览0评论

I created a program in Access 2021. When an error occurs the user sends the error to me via the code below (which I got from this site). The code worked fine but the last time it tried to send the email attachment (text file) I got the following error:

" -2147220975: The message could not be sent to SMTP server. The transport error code was 0x80040217. The server response was not available "

I logged on to the outlook email with the username and password (actual not shown below) and had no issues. Can anyone help me figure out what happened?

Set emailObj = CreateObject("CDO.Message")

emailObj.From = "[email protected]"
emailObj.To = "[email protected]"             '[email protected]
emailObj.Subject = "Error Log"
emailObj.TextBody = "From Debbie"
'emailObj.AddAttachment "c:\windows\win.ini"
emailObj.AddAttachment "C:\RDC-POS\Error Logs\ErrorLog.txt"

Set emailConfig = emailObj.Configuration


emailConfig.Fields(";) = 2
emailConfig.Fields(";) = 1
emailConfig.Fields(";) = 
"smtp.office365"
'Exclude the following line
'emailConfig.Fields(";) = 587
emailConfig.Fields(";) = True
emailConfig.Fields(";) = 
     "[email protected]"
emailConfig.Fields(";) = 
    "xxxYY2008"
emailConfig.Fields.Update

emailObj.send

If Err.Number = 0 Then MsgBox "Email has been sent!"
End Sub
发布评论

评论列表(0)

  1. 暂无评论