I have an MS Access VBA application that sends automatic emails using an Office 365 email account. It has been working perfectly fine, but it will stop working soon when Microsoft stops using Basic Authentication, I already registered the app in Microsoft Azure and did all the steps there to get it working, but I don't know the code in VBA to update my current function inside of the MS Access Application.
Here is my current code using Basic Authentication:
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/sendtls") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "outlook.office365.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
With iMsg
Set .Configuration = iConf
.to = "[email protected]"
.CC = ""
.BCC = ""
.FROM = "[email protected]"
.subject = "subject"
.TextBody = "body"
.Send
End With
CDO is not supported and not recommended for using any longer. Instead, you may consider automating Outlook where you don't need to care about authentication mechanisms. Here is what Microsoft states for that: