How to send email from Excel Macro from Outlook

December 17, 2011| Posted by : | Filled in Excel Macro, Popular Articles

This is continuation of my Previous Article you learnt How to Send Email From Excel VBA, using Gmail and Yahoo Email Account.

In my Previous Article, How to send email from Excel Macro, as you saw how to send email by Excel VBA from Gmail or Yahoo In this article you are going to learn how to send an email automatically by Excel VBA from my Outlook. Here in this you need to make sure that you have Outlook installed in your system where your excel macro is running. Also for sending email your Outlook must be configured already.
Before we get in to the code details, we need to add Microsoft Outlook 12.0 Object Librar reference in your Excel.
If you have not added this Reference then you need to create Outlook Objects run-time.

Adding Outlook Reference

Adding Outlook Reference

Sub SendEmailUsingOutlook()

Dim OlApp As New Outlook.Application
Dim myNameSp As Outlook.Namespace
Dim myInbox As Outlook.MAPIFolder
Dim myExplorer As Outlook.Explorer
Dim NewMail As Outlook.MailItem
Dim OutOpen As Boolean

    ' Check to see if there's an explorer window open
    ' If not then open up a new one
    OutOpen = True
    Set myExplorer = OlApp.ActiveExplorer
    If TypeName(myExplorer) = "Nothing" Then
        OutOpen = False
        Set myNameSp = OlApp.GetNamespace("MAPI")
        Set myInbox = myNameSp.GetDefaultFolder(olFolderInbox)
        Set myExplorer = myInbox.GetExplorer
    End If

    ' If you  don't to display your outlook while sending email then comment the below statement
    'otherwise you can un-comment


    ' Create a new mail message item.
    Set NewMail = OlApp.CreateItem(olMailItem)
    With NewMail
        '.Display ' You don't have to show the e-mail to send it
        .Subject = "Happy New Year"
        .To = ""
        .Body = "Wishing you happy New Year"
        .Attachments.Add ("C:\log.txt")
    End With

    If Not OutOpen Then OlApp.Quit

    'Release memory.
    Set OlApp = Nothing
    Set myNameSp = Nothing
    Set myInbox = Nothing
    Set myExplorer = Nothing
    Set NewMail = Nothing

End Sub

To know How to Send Email from Excel Macro using Gmail and Yahoo Account Read this Article

14 Responses to “How to send email from Excel Macro from Outlook”

  1. Sathish E says:

    Hi Vishwamitra,

    I want to know small coding to send simple email, can you help me on this,
    Email should be like,


    Could you please provide us the payment balances of XXXXXXX to be updated in Non-Netting Website for the month of Dec’14.

    Please provide us the details ASAP as we need to work with other restricted entities as well and update the same within XXXXXXXX.

    Sathish E

  2. This web site does not render correctly on my droid – you may want to try and repair that

  3. eshwar says:


    is there any macro to copy the any selected range data from excell and email

  4. Pradip says:

    Hi Vishwamitra,

    Your code gives me the type mismatch error. can you help with this?

    I am getting this error in

    ” Set NewMail = OlApp.CreateItem(olMailItem)”

    Please help.

    THanks again for writing such a nice blog.

  5. ori says:

    how can i forces the Language to be Hebrew or make the body Alignment = right



  6. Riis80 says:


    I have ahopefully quick question.

    How do you use an email adress, from a cell? or example if I have an email in excell i cell A1, how can that be inserted?


  7. Kalyan says:

    Hi ,

    Can i have any video reference does this works ..i tried but it dint work

    My requirement is i have excel where it get automatic updates from SQL Data Base …now we have to send this excel every day to Group Mails..sometimes we miss to send … with out our manual work …how to automate to send this excel sheet


  8. Priya says:

    Hi Vishwa… i tried tis macro…but my mail s getting stored in outbox… and the mail is not sent. why is it so?

    • Vishwamitra Mishra Vishwamitra Mishra says:

      Hi Priya,

      Remove this statement .Display from the code and try.

      With NewMail
      '.Display ' You don't have to show the e-mail to send it
      .Subject = "Happy New Year"
      .To = ""
      .Body = "Wishing you happy New Year"
      .Attachments.Add ("C:log.txt")
      End With

  9. […] previous Article, i had written how to Send Email from Excel Macro. In that article we had discussed how we can send any random file as an Attachment. But in this […]

  10. alfred beilin says:

    hi happy new year to yous all

    a beilin

Leave a Reply