Yes. In Excel for Microsoft 365 on Windows, a VBA macro can send email without Outlook by connecting directly to an SMTP mail server, commonly through Windows’ CDO.Message component. You need an SMTP server and credentials or permission to use a relay; this approach is not supported in Excel for the web and is generally unsuitable for Mac.
What “without Outlook” means
Outlook is one way for a VBA macro to create and send a message: the macro asks Outlook to handle the mail account and delivery. Without Outlook, the macro instead connects to an email service’s SMTP server. SMTP is the standard protocol used to submit outgoing email, and the server—not Excel—handles onward delivery.
A commonly used Windows approach is Collaboration Data Objects (CDO), accessed from VBA with CreateObject. CDO is a Windows component, not an Excel feature or a modern mail platform. The macro supplies message details such as the sender, recipient, subject and body, along with server settings. CDO then attempts to submit the message to that server.
This distinction matters: removing Outlook does not remove the need for an email service. You cannot send ordinary internet email just by putting a recipient address into VBA. Your mail provider or organization must allow the connection, and the server may require authentication, encryption, or a network-approved relay.
How the CDO method works
The example below uses late binding, so it does not require selecting a CDO reference under the VBA editor’s Tools > References menu. It demonstrates a single plain-text message sent through an SMTP server configured for authenticated submission on port 465. Replace the example server and account values with settings supplied by your provider. The port and encryption mode must match that provider’s requirements.
In the VBA editor, choose Insert > Module and paste the code into the module. Change the recipient and message fields before running it. The password shown is only a placeholder: do not put a real password into a workbook that other people can open.
Sub SendEmailWithoutOutlook()
' Illustrative SMTP settings; use values from your mail provider.
Dim message As Object
Dim config As Object
Dim fields As Object
On Error GoTo SendFailed
Set message = CreateObject("CDO.Message")
Set config = message.Configuration
Set fields = config.Fields
With fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.example.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "account@example.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "REPLACE_WITH_A_SECRET"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Update
End With
With message
Set .Configuration = config
.From = "account@example.com"
.To = "recipient@example.com"
.Subject = "Test from Excel"
.TextBody = "This message was sent by an Excel VBA macro."
.Send
End With
MsgBox "Message submitted to the SMTP server."
Exit Sub
SendFailed:
MsgBox "Email was not sent: " & Err.Description, vbExclamation
End Sub
The code uses CDO’s sendusing value 2 for an SMTP network connection, sets the server fields, updates the configuration, and calls .Send. A successful call means the server accepted the message for processing; it does not prove that the recipient received it or that it avoided a spam folder. The error handler displays a failure message rather than silently stopping.
Save a copy of the workbook before running a macro. VBA changes and actions generally cannot be undone with Ctrl+Z. On Windows, run the macro from the VBA editor with F5 or from Excel’s Developer > Macros command. Excel for Mac uses Option+F11 to open the VBA editor on many keyboards, but this CDO code will not work there because it depends on a Windows component.
Configure the mail server and account
Do not guess SMTP settings. Check your provider’s current instructions or ask your organization’s IT team for the SMTP host, port, encryption method, authentication requirements, and permitted sender address. Personal mail services and workplace mail systems can apply different rules, and a setting that works for one account may be rejected for another.
- Server: The SMTP hostname, such as a provider’s documented submission server. It is not necessarily the same as the incoming mail server.
- Port and encryption: Port 465 is commonly associated with implicit TLS, while port 587 is commonly used for message submission with STARTTLS. This sample requests SSL through CDO; it is not a universal recipe for STARTTLS on port 587.
- Authentication: Some servers require a username and password; others allow sending only through a managed relay or an approved network.
- Sender address: The server may require the From address to match the authenticated account or an address the account is authorized to use.
- Recipient and message policy: Providers can impose recipient, attachment, daily-volume, or anti-spam restrictions.
Many consumer and business providers have tightened authentication. A normal account password may not work in an older SMTP client, and some services require an app password when multifactor authentication is enabled. App passwords are not available for every account or policy. Microsoft 365 organizations may disable SMTP AUTH, while Gmail and other services can restrict basic username-and-password sign-in. Check the provider’s current rules rather than weakening account security to make a macro work.
Important limitations and compatibility
CDO is a legacy Windows technology. The Excel VBA example is aimed at desktop Excel running on Windows, where the CDO component is generally available. It does not run in Excel for the web, which cannot execute VBA macros. Excel for Mac does not provide the Windows CDO component, so this particular technique is not a cross-platform solution. If a workbook must work on both Windows and Mac, choose a different sending service and design a platform-specific or server-side approach.
Encryption compatibility can also be a blocker. CDO’s age means that its TLS behavior depends on the Windows environment and server requirements; modern providers may require protocols or authentication flows that CDO cannot negotiate. Setting smt pusessl to True is not the same as implementing every modern authentication method. If the provider requires OAuth 2.0, an interactive sign-in, or a particular STARTTLS exchange that CDO cannot perform, changing the port at random will not fix the underlying mismatch.
VBA runs on the user’s computer, so network access matters. A corporate firewall may block outbound SMTP, a VPN may change which relay is available, or the server may accept connections only from approved devices. An administrator may also prohibit macros or restrict sending from desktop applications. These are service and policy constraints, not errors in the worksheet itself.
Common errors and practical fixes
- “The transport failed to connect to the server”: Confirm the hostname, port, network connection, firewall rules, and whether the server permits SMTP from that computer.
- Authentication rejected: Verify the username format and account permissions. Check whether the provider requires an app password, SMTP AUTH to be enabled, or a different authentication method.
- SSL or secure-channel error: Confirm the provider’s required encryption and whether CDO on that Windows installation can meet its TLS requirements. If not, use a supported API or relay instead of repeatedly changing settings.
- Sender rejected: Make the From address an address the authenticated account is authorized to send as, or ask the mail administrator to configure the permission.
- Macro runs but no one sees the email: Check the recipient address, junk or quarantine folders, server logs, and sending limits. A successful .Send call is not a delivery receipt.
For diagnosis, first try a small plain-text message to an account you control, then check the exact error and the mail provider’s logs or support guidance. Avoid putting a real password into error messages, screenshots, shared files, or diagnostic worksheets. If the code runs from a managed workplace device, involve IT before testing against a company mail system.
Security and responsible use
A workbook containing a password is not a secure credential store. People who can access the file may be able to inspect its VBA project or extract the stored value, even if the sheet is protected. VBA project password protection is not a reliable way to safeguard mail credentials. A leaked SMTP password could allow someone to send messages as the account, subject to the provider’s limits.
Prefer an organization-approved relay, a managed secret store, or an authenticated service that does not require embedding a reusable password in the workbook. If a temporary test requires a credential, use a dedicated account with only the necessary permissions, follow provider guidance, and remove the secret from the file afterward. Never use someone else’s credentials or bypass an organization’s mail controls.
Also treat automated sending as a user-impacting action. A macro that sends a message for every row can create duplicates or exceed sending limits if run twice. Test with a controlled recipient, include a clear confirmation step for bulk jobs, validate addresses, and log which records were processed. Keep the workbook and code aligned with applicable organizational policies and consent requirements.
Alternatives when CDO is not suitable
If a mail provider rejects CDO or the workbook must run across platforms, choose a supported route rather than treating Outlook as the only alternative. The best option depends on the environment and whether a person must review each message.
- Microsoft Graph or another provider API: A web API can support modern authentication, but it requires correct application registration, permissions, token handling, and often administrator approval. This is more involved than a short macro and should be implemented with security in mind.
- Power Automate: A flow can send mail through a supported connector after Excel data is made available in an appropriate location. Connector licensing, data storage, and organizational policies can affect whether this fits.
- Outlook automation: If Outlook is installed and configured, VBA can use it to create or send messages. This relies on Outlook and may show security prompts or be restricted by policy; it is not the answer when Outlook must be absent.
- Approved SMTP relay: An administrator may provide a relay for internal applications, sometimes restricted to a trusted network or device. Ask for its authentication and sender rules rather than assuming anonymous relay is permitted.
For a one-off personal task, a mail client’s own interface may be simpler and safer. For recurring or high-volume business mail, a centrally managed service usually offers better credential control, monitoring, and failure reporting than a password embedded in a spreadsheet.
Frequently Asked Questions
Can Excel VBA send email without Outlook installed?
Yes, on Windows, VBA can submit email through an SMTP server using a component such as CDO, provided the server permits the connection and the required authentication works. Outlook is not required for that route.
Can I use Gmail SMTP from Excel VBA?
Possibly, but account security requirements apply. Gmail may require an app password for eligible accounts with two-step verification, and organizational accounts can have different administrator controls. CDO may also fail if its encryption or authentication capabilities do not meet Google’s current requirements.
Can I send from Excel for Mac or Excel online?
This CDO example is for Windows desktop Excel. Mac does not have the Windows CDO component, and Excel for the web does not run VBA macros. Use a service or workflow that supports the platform you need.
Does this macro send an email through my internet connection?
It connects to the configured SMTP server over the network. That server must accept the connection and authorize the sender; a recipient address alone does not provide a way to deliver mail.
Can a VBA macro send attachments?
CDO messages can include attachments, but the file path must exist and the provider’s message-size and attachment policies still apply. Validate paths and test with non-sensitive files before automating attachments.
Why does the macro work at home but fail at work?
Networks and mail policies differ. A workplace firewall, VPN, blocked outbound port, disabled SMTP AUTH, or required company relay can prevent the connection. Ask IT for the approved sending method rather than attempting to bypass those controls.
Related
- Microsoft Excel Solver Add-In: Setup and How It Works
- Microsoft Excel Shortcut Keys: Essential Commands
- Microsoft Excel Scenario Manager: Setup, Uses, and Limits
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- VBA InputBox With a Drop-Down List: Your OptionsNo: VBA’s built-in InputBox does not include a drop-down list, and Application.InputBox does not add one. To let…
- Excel VBA: Save a Worksheet as a New File SafelyTo save one Excel worksheet as a separate file with VBA, copy it to a new workbook with…
- Excel VBA: Find the Last Column in a Sheet or RangeTo find the last nonempty column in a specific row, start at the worksheet’s last column and move…
- VBA Check If a Worksheet Is Open in ExcelExcel does not open worksheets independently: a worksheet belongs to a workbook that is open in Excel. To…
- VBA Range Is Nothing? Meaning, Checks, and Common FixesIn Excel VBA, a Range is Nothing when an object variable does not currently refer to a range…
- Microsoft Excel VBA Dictionary: How to Use ItA Microsoft Excel VBA Dictionary is a key-and-value collection that lets a macro look up, count, and update…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.