Skip to content
Primary Menu
  • Officetricks.Com
  • Blog
  • App Store
    • International Users
    • Indian Users
  • Subscribe
  • About Us
  • Excel
  • Social Media

VBA Macro – Choose Outlook Email Account – To Send Mass Mail

June 03, 2025
Kumarapush

Choose From Multiple Outlook Email Accounts

[ Table of Contents ]
I. Choose From Multiple Outlook Email Accounts
II. Get All Email Accounts Configured in Outlook
III. Send Mail Using Outlook Email Accounts

Marketing people send tons of emails daily, to their customer base.

If a customer is not interested in the offer, there are chances that the marketing email could go to spam folder.

How to overcome this issue?

Marketing people use a different email account to send same offer to same set of email distribution list. In this case, the automation explained in this article will be useful.

This code selects one of the multiple Outlook email accounts configured in your system. To know how to automate sending emails from Outlook or Excel, refer this topic.

Get All Email Accounts Configured in Outlook

The loop in this code reads all the accounts configured in the MS Outlook email client. If you are using this code from within Excel VBA, then add this reference before executing the code.

Note: Go to Menu from VBA editor -> Tools -> Reference -> Microsoft Outlook Object Library.
Also, ensure that Outlook is properly for atleast one email account in your computer to use this code.

Sub List_Outlook_Email_Accounts()
    'Declare Outlook Object - Add reference to Microsoft Outlook Object Library
    Dim OutApp As Outlook.Application
    Dim oAccountIdx As Long

    'Create Outlook Object - Ensure Outlook is properly configured in your machine
    Set OutApp = CreateObject("Outlook.Application")

    'Loop through each Outlook Email Account
    For oAccountIdx = 1 To OutApp.Session.Accounts.Count
        MsgBox OutApp.Session.Accounts.Item(oAccountIdx) & " : This is account number " & oAccountIdx
    Next oAccountIdx
    
    'Process Completed
End Sub

If this reference is not added, then the Outlook Objects with the VBA code has to be created as late binding objects.

Now, we know how to reference difference email accounts with in Outlook. Now, lets see how to use any of them while sending any email.

Send Mail Using Outlook Email Accounts

You can choose the Email account within code wither with its index number as we saw in previous loop. Or use any of the other properties.

Sub Send_Emails_Using_Account()
    'Declare Outlook Object - Add reference to Microsoft Outlook Object Library
    Dim OutApp As Outlook.Application
    Dim oOutlookEmail As Outlook.MailItem
    Dim objSendUsingAcct As Outlook.Account
    Dim strAcctName As String
    Dim oAccountIdx As Long

    'Create Outlook Object
    Set OutApp = CreateObject("Outlook.Application")
    Set oOutlookEmail = OutApp.CreateItem(0)

    'Get Acct
    strAcctName = "officetricks123@gmail.com"
    For oAccountIdx = 1 To Application.Session.Accounts.Count
        If VBA.InStr(1, Application.Session.Accounts.item(oAccountIdx).UserName, strAcctName, vbTextCompare) Then
            Set objSendUsingAcct = Application.Session.Accounts.item(idxAcct)
            Exit For
        End If
    Next
    
    If objSendUsingAcct Is Nothing Then
        MsgBox "Account Not Found: " & strAcctName
    Else
        'Send Email Using Excel VBA Macro Code'
        With oOutlookEmail
            .To = "recepientId@gmail.com"
            .CC = ""
            .BCC = ""
            .Subject = "Happy New Year"
            .Body = ToMSg
            .SendUsingAccount = objSendUsingAcct
            .Display 'or just put .Send to directly send the mail instead of display
        End With
    End If
    
    Set OutlookMail = Nothing
    Set OutApp = Nothing
End Sub

This is how we can have just one Outlook, Configure multiple any number of email accounts & send our clients from the account of our choice.

We don’t have to switch through each account every time manually. This happens when you have multiple email accounts or you share the same machine with multiple persons.

In either case, here is the code that will enable you to opt for any email account from within VBA.

Tagged in : automate enail bulk email Choose Email Account Excel Send email mass email multiple Email accounts outlook vba send bulk email send mail sendusing

Related Articles

Rename a File in Python – or List of Files in a Folder – Free Code

VBA get Path to Default Temporary folder

VBA Combo box Add Items – from Excel Range or Array

Post navigation

Previous Previous post: Determine Operating System – Excel VBA Macro – Find OS Details
Next Next post: Copy WhatsApp Status Photo & Video
Excel Excel VBA Macro OutLook Outlook Macro
Excel Tricks
  • Software Downloads From Our App Store – Try Free & Buy
  • Excel VBA – Loop thru all Keys & Items in Dictionary
  • Excel Import Data – From another Workbook – Query External Source
  • Convert 2D Arary To 1D or List – Excel VBA Macro – Quickest Method
  • Excel VBA – Get Extended File Property – Author Modified Date Time
  • JSON Parser – Convert JSON To CSV – Excel VBA Macro
  • Convert Kg to Lbs – Feet To Meters, Miles – Liter to Gallon
  • Password Protect Excel 2010 & 2007
  • Excel VBA Code to Checks if File Exists in Path
  • Reading Process List From Task Manager
  • Compare Two Excel Sheets – Highlight Differences – Macro VBA Code
  • Excel VBA – Create Defined Name Formula & How to Use
  • Outlook VBA – Sort Emails by Date – in a Folder
  • Power BI – DAX
  • How to Run Macro – by Clicking Hyperlink – in Excel?
Excel VBA Macro Tricks
  • Non Repeating Unique Random Numbers – Fun with Excel
  • Open Text File – Read Write File Operations – VBA, Python, VBS, C, C++, DOS
  • Archive Facebook Messages – JSON to Excel
  • Excel VBA Get Stock Price – Google Finance – Best Live Stock Ticker
  • VCF to Excel Converter – Best Apps – 4 Easy Methods
OutLook Tricks
  • Open VCF File Online – Free VCF Viewers & Editors
  • Excel VBA Send Email at Specific Time – Outlook Delayed Delivery
  • [Outlook VBA] Select Appointments/Meetings Invites in Inbox
  • Printable 2022 Calendar Excel – Month Wise Template
  • Post to Facebook Timeline through Email
  • Creating Folders Using Python: A Simple Guide
  • A Simple Guide to Copying Excel Sheets
  • Retrieve All Files in a Directory using Python
  • Creating Folders in Outlook: A Guide
  • Chandrayaan 3 Live Stream Today – Vikram Lander
  • Creating Folders Using Python: A Simple Guide
    As the world of technology continues to advance, it becomes evident that the ability to manipulate, create, and manage digital spaces is of utmost importance. Python programming language is among the most powerful tools capable of such feats. This exciting exploration commences with an introduction to Python, providing essential knowledge […]
  • A Simple Guide to Copying Excel Sheets
    Navigating the intricate landscape of Microsoft Excel can often seem like a daunting task. This software, with its abundance of features, functions, and commands, requires a keen understanding to fully utilize its potential. Whether you’re an industry expert or a novice user, mastering the art of manipulating Excel sheets is […]
  • Retrieve All Files in a Directory using Python
    In our digitally driven world, where data processing and management are integral to many industries, the ability to work with Python has become an invaluable skill. This language, particularly in relation to file and directory manipulation, grapples with the rapid growth of data and its intricate handling. With its intuitive […]
  • Officetricks.Com
  • Blog
  • App Store
    • International Users
    • Indian Users
  • Subscribe
  • About Us
  • Excel
  • Social Media
Copyright All rights reserved