How to Specify the Sending Account in Outlook VBA | Access to Outlook
Question details
The user needs to know how to programmatically select a specific sender account when creating and sending an Outlook email from Microsoft Access VBA.

- Product
- Microsoft Outlook and Access
- Device & OS
- not provided
- Scenario
- Automating email creation in Access VBA when multiple Outlook accounts are configured, requiring the script to choose an account other than the default.
- Observed behavior
- By default, Outlook VBA uses the primary account to send emails. The user must find a way to specify a different configured account or a shared mailbox before the email is sent.
Ensure you have added the 'Microsoft Outlook Object Library' reference in your Access VBA editor (Tools > References) to access early-bound Outlook objects and properties.
Use SendUsingAccount to Select a Specific Configured Account
Iterate through your configured Outlook accounts and assign the matching Outlook.Account object to the SendUsingAccount property.
When multiple accounts are configured in Outlook, sending an email via Access VBA defaults to the primary account. To change this, you must assign a valid Outlook.Account object to the MailItem.SendUsingAccount property.
Create an instance of the Outlook Application and a new MailItem object in your Access VBA module.
Use a 'For Each' loop to iterate over the `Application.Session.Accounts` collection to evaluate all available accounts.
Compare each account's SmtpAddress with your desired sender email address. Once found, set `MailItem.SendUsingAccount` to that specific account object before displaying or sending the email.

Use SentOnBehalfOfName for Shared Mailboxes
Use this property if you are sending an email on behalf of a shared mailbox or another user account.
Looking for a Fast and Reliable Office Alternative?
If you frequently work with automation, VBA, and data integration, you understand the value of a powerful office suite. WPS Office provides excellent compatibility with Microsoft Word, Excel, and PowerPoint files while offering a lightweight, cost-effective alternative for your daily document needs.
- 1. Download WPS Office: Visit the official WPS website and download the free installation package.
- 2. Install the Suite: Run the installer and follow the on-screen instructions to set up WPS Office on your device.
- 3. Open and Edit Files: Launch WPS Office to seamlessly open, edit, and save your existing Microsoft Office documents.

Frequently Asked Questions
Why do I get a Type Mismatch error when setting SendUsingAccount?
This usually occurs if you try to assign a text string of the email address instead of an Outlook.Account object. You must iterate through Application.Session.Accounts to find and assign the actual object variable.
Can I use SentOnBehalfOfName without delegate permissions?
No. Your Exchange administrator must grant your primary authenticated account 'Send As' or 'Send on Behalf' permissions for the target address. Without these permissions, the email will bounce back or remain stuck in the Outbox.
How can I check which Outlook accounts are available via VBA?
You can write a quick VBA macro to loop through `Application.Session.Accounts` and use `Debug.Print` to output the `SmtpAddress` or `DisplayName` of each configured account to the Immediate Window in the VBA editor.




