Nowadays, it is quite likely that you have multiple email accounts configured in Outlook.
Especially when working from home, you don’t want to end up sending your business emails via your private account or vice versa.
Also, when you have access to a Shared Mailbox or are a delegate for the mailbox of a colleague, you could find yourself inadvertently send from these mailboxes or forget to select it when needed.
By adding this simple VBA macro to Outlook, you can prevent sending emails from the wrong email address.
Check Sending Account VBA macro
The CheckSendingAccount macro shows you a dialog with your selected sending account or also even the address, for each emails that you send.
There is nothing else that you need to configure or change about your sending routine; You press the Send button and Outlook shows you the following dialog box;
When you send from an address which is different from the primary address of your account, you’ll be notified in the following way;
This can for instance occur when you have a second address (alias) assigned to your account or when sending on behalf of a Shared Mailbox or a colleague or manager as a Delegate.
Press the OK button to send the message or press Cancel to prevent sending the message. When cancelling, you’ll return to your message Draft so you can adjust the sending account and/or From address of the message.
Quick Install
Use the following instructions to configure the macro in Outlook;
- Download this code-file (
checksendingaccount.zip
) and copy the code from theCheckSendingAccount.txt
file or copy the code below. - Open the VBA Editor (keyboard shortcut ALT+F11)
- Paste the copied code in the ThisOutlookSession module.
- Sign your code so you won’t get any security prompts and the macro won’t get disabled.
ThisOutlookSession module in the VBA Editor.
Macro Code
The following code is contained in the zip-file referenced in the Quick Install. You can use the code below for review or manual installation.
'Always verify sending account and from address. 'Place in ThisOutlookSession Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) If (TypeOf Item Is MailItem) Then Dim strMsg As String Dim msgResult As Integer strMsg = "This message will be sent with the following account:" & _ vbNewLine & vbNewLine & Item.SendUsingAccount 'Check whether it is sent with a different From address of the account If Item.SenderEmailAddress <> Item.SentOnBehalfOfName Then strMsg = strMsg & vbNewLine & vbNewLine & _ "and with the following From address:" & _ vbNewLine & vbNewLine & Item.SentOnBehalfOfName End If msgResult = MsgBox(strMsg, vbOKCancel + vbDefaultButton1 + vbQuestion, _ "Account check") If msgResult = vbCancel Then Cancel = True End If End If End Sub
Check Sending Account with an add-in
Instead of using a macro, you can also use an add-in to control or assist you with selecting the right account and/or address when sending an email.
They can give you a prompt similar to the macro or you can define rules so the right account and address is selected automatically.
Some popular add-ins which can do this are;
Safeguard Send by Sperry Software
- Contains many configurable warnings like whenever you …
- …send an email outside your company’s domains.
- …send an email where the From address does not match the signature line.
- …send an email where the From address contains specific words.
- …many more
- Discount code: BH93RF24
MAPILab Toolbox (Message AutoFill module) by MAPILab
- Contains 20 (small) handy modules like Message AutoFill to automatically set the sending account and/or From address based on the folder that you are in.
- Other modules like…
- …vCard Converter
- …Find and Replace
- …Reminders Assistant
- …”Reply All” Forget
- Discount code: 4PM76A8
SAM by VBOffice
- Set your desired sending account for every e-mail.
- Sent items are stored in a folder of your choice or deleted immediately if you so choose.
- Public Exchange folders are supported.
- Save your rules on a file server and share them with other users.
- Supported are rules based on the recipient’s address, email categories, contact categories, and folders/mailboxes.
For more add-ins see; Outgoing mail management add-ins