How to Fix Hotmail SMTP Email Sending Errors in Excel VBA
Question details
The user needs to resolve an issue where legacy Excel VBA code fails to send emails through Hotmail or Outlook.com SMTP servers.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Running an Excel VBA macro designed to send automated emails using a Hotmail or Outlook.com account.
- Observed behavior
- The VBA SMTP code stops working and fails to send emails, even with an app password and two-factor authentication enabled, due to the deprecation of basic authentication.
Verify that your Microsoft account is active by logging into Outlook.com on a web browser, and ensure your local network or firewall allows outgoing traffic on SMTP port 587.
Update VBA CDO Settings and Use an App Password
Configure your VBA script to use the latest supported Outlook.com SMTP server details and authenticate securely with an App Password.
Microsoft has largely deprecated legacy basic authentication. To continue using VBA CDO (Collaboration Data Objects) for sending emails, you must ensure your script connects to the modern SMTP endpoints and bypasses standard password entry by using an App Password.
Log into your Microsoft account's Security dashboard. Ensure Two-Step Verification is enabled, then navigate to 'App passwords' and generate a new unique password. Replace your standard account password with this new app password in your VBA script.
In your VBA CDO configuration code, locate the server setting and change the 'smtpserver' property value to 'smtp-mail.outlook.com'.
Set the 'smtpserverport' property to 587. Ensure that SSL/TLS is enabled by setting the 'smtpusessl' or 'sendtls' property to True.

Migrate to Microsoft Graph API or Power Automate
If VBA CDO continues to fail due to strict modern authentication (OAuth2) policies, transition your email automation to fully supported modern APIs.
Automate Your Spreadsheets with WPS Office
While modern authentication policies complicate legacy Excel VBA email sending, WPS Office offers a robust, lightweight, and highly compatible alternative for your spreadsheet automation and daily document needs. Enjoy seamless format compatibility without the heavy subscription fees.
- 1. Download and Install: Visit the official WPS Office website to download and install the free, lightweight suite on your Windows, Mac, or Linux machine.
- 2. Open Your Spreadsheets: Launch WPS Spreadsheets and open your existing .xlsx or .xlsm files directly. WPS handles Microsoft formats seamlessly.
- 3. Manage Data Easily: Take advantage of familiar formulas, charting tools, and data processing capabilities to manage your workflows effortlessly.

Frequently Asked Questions
Why did my Excel VBA email script suddenly stop working with Hotmail?
Microsoft has aggressively phased out basic authentication for email protocols in favor of Modern Authentication (OAuth2) to improve security. Older VBA scripts using CDO rely on basic authentication, which is now blocked even if you provide the correct username and password.
Can I still use CDO.Message in VBA to send emails via Outlook.com?
Yes, but it requires having Two-Factor Authentication (2FA) enabled on your Microsoft account and generating a unique 'App Password' to use in your VBA script instead of your standard Microsoft account password.
Where can I get specialized programming help if my VBA email code still fails?
Programming questions related to VBA are best suited for developer forums like Stack Overflow. When posting, be sure to use the 'vba' tag, include your sanitized code, and provide detailed error messages so the developer community can assist you effectively.




