Yes, you can send email from a specific account in Excel VBA by using the SendUsingAccount property of the MailItem object in Outlook. This lets you choose which configured Outlook account sends the message, rather than always using the default. You will need Excel and Outlook installed on the same machine, with the target account already set up in Outlook. The steps below show how to write the macro, select the account by its display name or index, and handle common issues.

What You'll Need

  • Microsoft Excel (any modern desktop version) and Microsoft Outlook installed on the same computer.
  • The Outlook account you want to send from already configured and working in Outlook.
  • Basic familiarity with the VBA editor (ALT+F11) and how to enable macros.
  • Permission to send email from that account (some organisations restrict this).

Step-by-Step

  1. Open the VBA editor. In Excel, press ALT+F11. If the Developer tab is not visible, you can still use the shortcut. In the editor, insert a new module via Insert > Module.
  2. Add a reference to the Outlook object library. In the VBA editor, go to Tools > References. Scroll down and tick Microsoft Outlook 16.0 Object Library (the version number may differ). Click OK. This step is optional if you use late binding, but early binding gives you IntelliSense and named constants.
  3. Write the macro skeleton. Start with Sub SendFromSpecificAccount() and declare variables for the Outlook application, mail item, and account. For example:
    Dim olApp As Outlook.Application
    Dim olMail As Outlook.MailItem
    Dim olAccount As Outlook.Account
    Set olApp = New Outlook.Application
    Set olMail = olApp.CreateItem(olMailItem)
  4. Identify the target account. You can loop through olApp.Session.Accounts and match the DisplayName or SmtpAddress property. For example, to select the account named "Work":
    For Each olAccount In olApp.Session.Accounts
        If olAccount.DisplayName = "Work" Then
            Set olMail.SendUsingAccount = olAccount
            Exit For
        End If
    Next olAccount
    If no match is found, SendUsingAccount remains the default account.
  5. Compose the email. Set the To, Subject, and Body properties. For example:
    olMail.To = "recipient@example.com"
    olMail.Subject = "Test from specific account"
    olMail.Body = "This message was sent from the Work account."
  6. Send or display the email. Use olMail.Send to send immediately, or olMail.Display to review first. Always release objects at the end:
    Set olMail = Nothing
    Set olApp = Nothing
  7. Run the macro. Press F5 in the VBA editor or assign the macro to a button. Check the Sent Items folder of the specified account to confirm it was sent from there.

Common Mistakes

  • Not setting SendUsingAccount before sending. If you set it after calling Send, it has no effect. Set it before you populate or send the message.
  • Using the wrong account name. Display names are case-sensitive and may include spaces. Use the exact string from Outlook's Account Settings, or match on SmtpAddress instead.
  • Forgetting to release objects. Leaving Outlook running invisibly can cause memory issues. Always set objects to Nothing.
  • Assuming SendUsingAccount works with all account types. It works for Exchange and IMAP/POP accounts configured in Outlook, but not for shared mailboxes unless you have send-as permission and the account is added to your profile.
  • Ignoring security prompts. Outlook may show a warning when a program tries to send email. This is normal and cannot be bypassed by VBA alone.

Tips

  • Use olMail.SendUsingAccount = olApp.Session.Accounts.Item(1) to quickly pick the first account by index, but be aware the order can change.
  • Store the account name in a cell and read it into a variable to avoid hard-coding.
  • Test with Display before using Send to verify the correct account is selected.
  • If you need to send from a shared mailbox, add it as an additional account in Outlook first; then it appears in the Accounts collection.

Troubleshooting

If the email sends from the wrong account, check that the account name matches exactly and that the loop actually finds it. Add a message box to display olAccount.DisplayName for each account to see the exact strings. If you get a "Subscript out of range" error, the account index you used does not exist. If Outlook prompts for permission or blocks the send, adjust your macro security settings in the Trust Center (File > Options > Trust Center > Trust Center Settings > Macro Settings) or use a digitally signed macro. If the macro runs but no email appears, ensure Outlook is running and that you have not accidentally set olMail.SendUsingAccount to Nothing.

Frequently Asked Questions

Can I send from a shared mailbox using SendUsingAccount?

Only if the shared mailbox is added as a separate account in your Outlook profile. Otherwise, you need to use the SentOnBehalfOfName property, which requires delegate permissions.

Does SendUsingAccount work with Outlook on the web or mobile?

No, this is a desktop Outlook feature. VBA runs only in desktop Excel and controls desktop Outlook.

Why does my macro always send from the default account?

Most likely the account name you specified does not match any in the Accounts collection, so the property is never set. Verify the exact display name or use SmtpAddress.

Can I use this with multiple accounts in a loop?

Yes, you can set SendUsingAccount for each mail item individually before sending. Just ensure you create a new MailItem for each send.

What if I get a "Permission denied" error?

Your organisation may restrict programmatic sending. Check with your IT administrator; there is no VBA workaround for policy blocks.