Send Email from Excel VBA Using Yahoo SMTP and CDO
Question details
The user needs to send an email from a VBA macro through Yahoo Mail using CDO SMTP settings.

- Product
- Microsoft Excel VBA with CDO and Yahoo Mail SMTP
- Device & OS
- not provided
- Scenario
- A workbook macro must authenticate with Yahoo Mail and send an email through Yahoo's SMTP server.
- Observed behavior
- A normal Yahoo account password may be rejected because Yahoo SMTP requires SSL, authenticated access, and a Yahoo app password.
Create a Yahoo app password in your Yahoo Account Security settings before running the macro. Confirm that the VBA project can use the CDO.Message object on the Windows computer where the workbook will run.
Configure CDO with Yahoo SMTP SSL and an app password
Use this configuration when your VBA macro sends mail through a Yahoo Mail account.
Yahoo Mail SMTP requires authenticated access over SSL. Use smtp.mail.yahoo.com on port 465 and enter a Yahoo-generated app password instead of your normal Yahoo account password.
Sign in to Yahoo Mail, open Account Info > Account Security, and create an app password for your mail application. Copy the generated password for use by the macro.
In the VBA editor, press Alt+F11, open your module, and configure CDO.Configuration.Fields with sendusing = 2, smtpserver = "smtp.mail.yahoo.com", smtpserverport = 465, smtpusessl = True, and smtpauthenticate = 1.
Set sendusername to your full Yahoo email address and sendpassword to the Yahoo app password. Then call .Fields.Update before sending the CDO.Message.
Use CDO.Message.From, .To, .Subject, and .TextBody or .HTMLBody, then call .Send. Add an On Error GoTo handler so the macro can display the SMTP error description if sending fails.

Store credentials outside shared VBA code
Use this approach when the workbook is distributed, stored in a shared location, or used by multiple people.
Use WPS Spreadsheet to Work with Yahoo SMTP VBA Email Macros
WPS Spreadsheet provides a familiar spreadsheet workspace for opening compatible macro-enabled workbooks and maintaining VBA-based email workflows. Configure the Yahoo SMTP server, SSL port, authentication details, and app password in the macro before running it in a supported macro environment.
- 1. Open the macro-enabled workbook: Launch WPS Spreadsheet and use Menu > Open to select the compatible XLSM workbook containing the email macro.
- 2. Review the VBA email settings: Open the workbook's macro or VBA editor, then verify smtp.mail.yahoo.com, port 465, SSL, SMTP authentication, the Yahoo email address, and the app password.
- 3. Enable macros when prompted: When WPS Spreadsheet displays a macro security prompt for a trusted workbook, enable macros so the VBA procedure can run.
- 4. Run and test the email procedure: Open the Macro dialog from the Developer or Tools area, select the email procedure, choose Run, and confirm that the test message arrives at the recipient address.

Frequently Asked Questions
What Yahoo SMTP server should I use in a VBA CDO macro?
Set the CDO smtpserver field to "smtp.mail.yahoo.com". Use smtpserverport 465 with smtpusessl set to True.
Why does Yahoo reject my normal account password in VBA?
Yahoo SMTP commonly requires an app password for third-party applications. Create one in Yahoo Account Security and assign it to the CDO sendpassword field.
Which CDO authentication settings are required for Yahoo Mail?
Set sendusing to 2 for SMTP over the network and smtpauthenticate to 1 for basic authentication. Also set sendusername to the full Yahoo email address.
Can I use port 587 instead of port 465 for Yahoo SMTP CDO?
This configuration uses Yahoo SMTP SSL on port 465 with smtpusessl = True. If you change the port, verify that the CDO SSL and transport settings match the connection method supported by your environment.
How can I avoid exposing a Yahoo app password in an Excel workbook?
Do not place the app password as plain text in a shared VBA module. Retrieve it from an approved secure credential store or request it at runtime, and keep the VBA project access-controlled.




