Last reviewed on July 15, 2014   —  20 Comments

Macro using the Default Account

An IMAP user created this macro to open a new message form from any message store and use the default account as assigned in Account Settings.

To use: Go to File, Options, Customize Ribbon. Select Macros from Choose Commands from dropdown, add a New Group to Home tab then add the New Mail macro to the new group. Click the Rename button to rename the command and choose a better looking icon.

Text file containing both macros on this page.

Public Sub New_Mail()
Dim olNS As Outlook.NameSpace
Dim oMail As Outlook.MailItem

Set olNS = Application.GetNamespace("MAPI")
Set oMail = Application.CreateItem(olMailItem)

'use first account in list
    oMail.SendUsingAccount = olNS.Accounts.Item(1)
Set oMail = Nothing
Set olNS = Nothing

End Sub

See Using VBA Codeif you need help using VBA code.

Macro using a specific account

This macro is assigned to a button on the ribbon - clicking the button selects the account listed in the code. Replace Name_of_Default_Account with your account name (check in Account settings for the account name). You can create a macro for each account (change the Public Sub name) if desired.

Go to File, Options, Customize Ribbon. Select Macros from Choose Commands from dropdown, add a New Group to Home tab then add the New Mail macro to the new group. Click the Rename button to rename the command and choose a better looking icon.

If you need help customizing the ribbon, see Customizing the Quick Access Toolbar (QAT)

See Using VBA Code if you need help using VBA code.
Text file containing both macros on this page.

Public Sub New_Mail()
Dim oAccount As Outlook.Account
Dim oMail As Outlook.MailItem

For Each oAccount In Application.Session.Accounts
   If oAccount = "Name_of_Default_Account" Then
      Set oMail = Application.CreateItem(olMailItem)
      oMail.SendUsingAccount = oAccount
   End If
End Sub

Note: this macro also works with Outlook 2007 (possibly older versions).

Set the From address on a message

Similar to the previous macro, except it uses a different From address, not a different email account in your profile. Because the message is sent from the default email account, the default account needs Send As permission for the address.

If the account does not have Send as permission, the message will be sent from the default account on behalf of the address or will bounce if using Exchange server. If you are using a SMTP server the message may be sent from the default account.

Use this code to fill in the From field with an address you have permission to send messages From.

Public Sub CreateNewMessageFrom()
Dim objMsg As MailItem

Set objMsg = Application.CreateItem(olMailItem)

 With objMsg
    .SentOnBehalfOfName = ""
    .BCC = ""
End With

Set objMsg = Nothing
End Sub

Send a meeting request using a specific account

Use this macro to send meeting requests using a specific account, irregardless of which data file you are viewing.

Public Sub NewMeeting()
Dim oAccount As Outlook.Account
Dim oMeeting As Outlook.AppointmentItem

For Each oAccount In Application.Session.Accounts

If oAccount = "account@displayname" Then
    Set oMeeting = Application.CreateItem(olAppointmentItem)
       oMeeting.MeetingStatus = Outlook.OlMeetingStatus.olMeeting
      oMeeting.SendUsingAccount = oAccount
End If

End Sub

Using VBA Code

To use VBA code, press Alt+11 to open the VBA Editor. Locate ThisOutlookSession and paste the code into the editor.

Press F5 or the Run button to test the macro. (It's highly recommended you make a backup of the folder or message store before running macros.)

You'll also need to change macros security or use selfcert.exe to sign your macros. Access the dialog to change the security level from Tools, Macros, Security. (This is at File tab, Options, Trust Center, Macro Security in Outlook 2010). Set it on "always ask". Do not choose the Low option (run all, never ask). Some security software will set it to High and your macros will not run.

To run a macro later, press Alt+F8 to open the macro dialog, then select the macro and choose Run. Or add a button for the macro to your toolbar or add it to the QAT in Outlook 2010.

More Information

How to Enable the Developer Ribbon
See How to use VBA code samples in Outlook for more detailed information on using macros and selfcert.


  1. Robert says

    I want to thank you so much for this, I have searched literally for years on how to email from specific accounts without having to remember to switch accounts in the email. Such a lifesaver.

  2. Dave Englund says

    Diane, thanks for providing these code snippets! Now, I have a question :D

    We currently use a bit of code called "ReplyWithAttachments" because Outlook does not include attachments in a Reply All, and our Help Desk needs to include the original attachments on all our correspondence. So, we use this nifty "ReplyWithAttachments" code to do that. Now, what I'm wondering is, would you be able to incorporate your "using a specific account" code into our "ReplayWithAttahments" code? This would solve some problems for us, in that we could ensure that when we use this our "From" will always be the Help Desk address rather than our personal address. Here's the "ReplyWithAttachments" code:

    Sub ReplyWithAttachments()
    ' Keyboard Shortcut: Ctrl+w
    Dim rpl As Outlook.MailItem
    Dim itm As Object

    Set itm = GetCurrentItem()
    If Not itm Is Nothing Then
    Set rpl = itm.ReplyAll
    CopyAttachments itm, rpl
    End If
    Set rpl = Nothing
    Set itm = Nothing
    End Sub

    Function GetCurrentItem() As Object
    Dim objApp As Outlook.Application

    Set objApp = CreateObject("Outlook.Application")
    On Error Resume Next
    Select Case TypeName(objApp.ActiveWindow)
    Case "Explorer"
    Set GetCurrentItem = objApp.ActiveExplorer.Selection.Item(1)
    Case "Inspector"
    Set GetCurrentItem = objApp.ActiveInspector.CurrentItem
    Case Else
    ' anything else will result in an error, which is
    ' why we have the error handler above
    End Select
    Set objApp = Nothing
    End Function

    Sub CopyAttachments(objSourceItem, objTargetItem)
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
    strPath = fldTemp.Path & "\"
    For Each objAtt In objSourceItem.Attachments
    strFile = strPath & objAtt.FileName
    objAtt.SaveAsFile strFile
    objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
    fso.DeleteFile strFile
    Set fldTemp = Nothing
    Set fso = Nothing
    End Sub

  3. FP says

    Thank you for this. Very helpful. Only trouble I had was with the instructions on changing macro security for the 2010 version. I found it at File Tab/Options/Trust Center/Trust Center Settings/Macro Settings. And then I selected Notifications for all macros.

  4. JDL says

    I am truly having a hard time with this.

    I run Outlook 2013 against Exchange server.

    I am connected to two Exchange accounts. My personal one is just my name at my instution (, and I was recently made the coordinator for another department and given full permissions over the department's e-mail (

    I am trying to set up User-Defined Forms that allow me to send various form e-mails, form meeting requests, and things of the sort very quickly, so I am saving them as .OFT files and I am using your simple macro and attaching those to buttons on a custom ribbon to call them up in a single click! For routine E-MAIL messages, it works like a charm. I created them while working in the LAP account, and when I call it up, it comes up automatically as being sent FROM the LAP account (just the way I want it!)

    For MEETING REQUESTS, though, not so much. I CREATED the .OFT while working in the LAP account, then saved the macro and attached it to a button, but when I call up the meeting request macro, there is virtually NO "From" option. In fact, it's blank. When I do send that meeting request to its intended recipients, it shows up in their email as coming from " ON BEHALF OF" I cannot change this at all. There's no option to change the "From" account.

    The funny thing is that when I create a meeting request MANUALLY, going through the steps from scratch, I can send the request from whatever account I want. It's ONLY when I create an .OFT template that it won't let me choose the FROM account.

    What is it I'm not seeing/knowing/doing right?!?! This is frustrating!

    Thank you for whatever feedback you afford me in advance!

    • Jayson Levine says

      Thank you! I will be eager to know what you find on this one! I don't have much hair, but what I have, I'm pulling out! I can't imagine why I'd be perfectly able to choose the account from which I send a meeting request manually/from scratch, but be completely locked out from any choice in the matter by creating a meeting request user form .oft file aand bringing that up either through the standard "Choose a Form" method or by executing a macro that quickens the process.

  5. Suraj Singh says


    I am new to VBA and recently started working on Macros with Excel.

    I have a problem. I have two outlook Profiles say Profile A and Profile B. When I created a macro in the Excel using VBA, with specific user ID's who belong to Profile B. I have also created a button in Excel sheet which when clicked will open an Outlook email with those ID's in "cc" column. Now, my problem is when I click on the create button in Excel sheet Profile A's Outlook is being generated and the user ID's do not belong to Profile A. How can I change the Outlook profile in VBA or Excel or set the outlook profile name to a specific profile. Kindly help.

    • Diane Poremsky says

      I'm guessing Profile A is set as default or Outlook is open to that profile. If outlook isn't running, code will open the default profile. If you have outlook set to ask which profile, then it should ask you which to use. If outlook is running, it's going to use the profile that is open.

  6. Dale Frey says

    Hi Diane

    I very much appreciate you sharing your knowledge on this page it is helpful.

    I do have a question, when replying to existing mail in a secondary account how would I by default be able to have the From address be different from my personal mail account by default?

    I am on Outlook 2010 and have a support account automatically open for quick navigation between my personal and business accounts. The code above works great for new messages but not being a programmer, I am lost on what changes I can make to better myself. Appreciate your advice.

    • Jamie M. says

      Thanks for the great code Diane! I tried to get the reply button VBA code working with the "use default from account" code above but to no avail. I'm not very experienced with VBA. If possible could you write the VBA code for a "reply" button that uses the "default" account reguardless of the account the message came in on? Thanks!

      -Jamie M.

    • Diane Poremsky says

      For replies, it would be better to pick up the reply button click (I'll add code for it)... but if the account is POP3 or IMAP and you want to always reply using a specific account, you can change the SMTP information on the account to the desired account, similar to the method shown here. The sending account's email address and display name goes at the top, along with it's SMTP server name.

    • Jamie M. says

      It's exchange, hence why I can't change the SMTP information. I have to use a dummy outgoing account, and need it to default to it always, even for replies. If it could pick up the real reply button click that would be amazing! Thanks again :)

      -Jamie M.

    • Diane Poremsky says

      Unless you have an Exchange account that does not have SMTP enabled, you could use a dummy account. (GoDaddy's Office 365 doesn't enable SMTP, not sure about other resellers. )

      In any event, I'll see what I come up with. I'm working on a macro for a company that uses single member distribution groups to send from additional addresses. After it's finished and tested I'll post it here.

    • Diane Poremsky says

      you'd need to check the sent items folder - maybe get the to and subject when its added to the sent folder and compare it to the one you thought you sent. Once it leaves Outlook, the only way to confirm it reached the recipient is with using read and delivery receipts, which are notoriously unreliable. Or using "web bugs", which are also unreliable.

  7. Adrian Knight says


    I was trying to achieve the same thing, but get the VBA script triggered when I click "Reply" / "replyall" / "Forward". If I run the macro from the MVB directly it opens the selected message and replaces my from address field with the default account. I just can't get it to work when I click "Reply" on an email.

    So the end-goal: When I click reply/replyall/forward on messages on another account in Outlook 2010 (autodiscover , exchange accounts), to have the FROM address always one specific account (default one pref).

Leave a Reply

Please post long or more complicated questions at OutlookForums by

If the Post Comment button disappears, press your Tab key.