The code for VBA is almost the same as VBScript and I tested it using Excel 2016 without any problems at all. ObjMessage.Send VBA to send email via Office 365 () Set objConfig = CreateObject("CDO.Configuration") Set objMessage = CreateObject("CDO.Message") This is just quick sample code to get you on the right path: Dim objMessage, objConfig, Fields The trick is not to use TLS at all, but to use SSL instead on port 25 instead, which seems to work fine: VBScript to Send Email via Office 365 () So clearly the TLS support in CDO is not sufficient to be able to work with the Office 365 SMTP Server. The server response was: 530 5.7.57 SMTP Client was not authenticated to send anonymous mail during MAIL FROM So I tried in vain to develop some code that would send email via using TLS and always came up with the following error: The problem is that officially CDO does not support TLS, but unofficially it does. I knew from configuring other devices and software that the preferred way to setup SMTP to relay to Office 365 was to use TLS on port 587. Sending email via VBScript or VBA using CDO is easy to do, but the correct configuration to relay through Office 365 is confusing to say the least and it took me me a while to find the correct settings.
0 Comments
Leave a Reply. |