Yes, you can automate sending Excel data via email using a macro—without needing advanced coding knowledge—by leveraging VBA’s built-in Outlook.Application object. This method works for static data, dynamic ranges, or even formatted tables, but it requires Outlook to be installed and configured on the same PC. Below is a foolproof guide covering setup, troubleshooting, and avoiding pitfalls.

What You'll Need

  • Microsoft Excel 2013 or later (VBA enabled)
  • Microsoft Outlook installed on the same computer (no cloud-only Outlook accounts)
  • A predefined email template (optional but recommended for consistency)
  • Basic familiarity with Excel’s ribbon interface (if not, pause here and enable macros in File > Options > Trust Center > Macro Settings)
  • Permissions to send emails from the PC’s configured Outlook profile (admins may need to grant macro permissions)

Step-by-Step

  1. Open your Excel workbook and press Alt+F11 to launch the VBA Editor. This will display the project explorer on the left.
  2. Insert a new module:
    1. Right-click in the Project Explorer window on VBAProject (YourWorkbookName).
    2. Select Insert > Module. A blank code window will open.
  3. Paste this basic macro template (adjust range and email details below):
    Sub SendEmailWithExcelData()
        Dim OutlookApp As Object
        Dim OutlookMail As Object
        Dim ws As Worksheet
    
        'Set the worksheet containing your data
        Set ws = ThisWorkbook.Sheets("Sheet1") 'Change to your sheet name
    
        'Check if Outlook is installed
        On Error Resume Next
        Set OutlookApp = GetObject(, "Outlook.Application")
        If Err.Number <> 0 Then
            MsgBox "Outlook is not installed or not available.", vbCritical
            Exit Sub
        End If
        On Error GoTo 0
    
        'Create a new email
        Set OutlookMail = OutlookApp.CreateItem(0) '0 = mail
    
        'Configure email subject and body
        With OutlookMail
            .Subject = "Automated Excel Report: " & Format(Now(), "mm/dd/yyyy")
            .To = "recipient@example.com" 'Replace with recipient email
            .Body = "Please find the attached report below." & vbNewLine & vbNewLine & _
                    "Data Summary:" & vbNewLine & _
                    ws.Range("A1").CurrentRegion 'Displays table header + data
    
            'Attach the entire sheet or selected range
            '.Attachments.Add ws.Path & "\" & ws.Name & ".xlsx" 'Uncomment for full workbook attachment
            '.Attachments.Add ws.Range("A1:D100").SpecialCells(xlCellTypeConstants).Address & ".xlsx" 'Uncomment for range export
    
            'Set attachment to just the used range (preferred for small datasets)
            Dim attachmentPath As String
            attachmentPath = ThisWorkbook.Path & "\Temp_Report.xlsx"
            ws.Copy
            ActiveWorkbook.SaveAs attachmentPath, FileFormat:=xlOpenXMLWorkbook
            .Attachments.Add attachmentPath
            ActiveWorkbook.Close SaveChanges:=False
        End With
        
  4. Customize the macro:
    1. Replace "Sheet1" with your worksheet name (verify via the worksheet tab).
    2. Update the .To email address(es) with semicolons for multiple recipients: "recipient1@example.com;recipient2@example.com".
    3. Modify the subject line (e.g., to include a report name or date).
    4. For large datasets, uncomment the attachment lines to export only the used range (lines 22–23) or the entire workbook (line 20).
  5. Test the macro:
    1. In the VBA Editor, click the Run button (green arrow) or press F5.
    2. If prompted by Outlook’s security warning, click Yes to enable macros.
    3. Check your Outlook Drafts folder to verify the email was created without errors.
    4. Send a test email to yourself to confirm formatting and attachments.
  6. Assign the macro to a button or shortcut (optional but recommended):
    1. Return to Excel and go to the Developer tab (enable it via File > Options > Customize Ribbon if missing).
    2. Click Insert > Button and choose Assign Macro.
    3. Select your macro from the list and click OK.
    4. Drag the button to your Quick Access Toolbar or worksheet for one-click access.

Common Mistakes

  1. Forgetting to check Outlook’s availability: The macro will fail silently if Outlook isn’t installed or is closed. Always include the error-handling code (lines 8–12) to alert users.
  2. Incorrect worksheet or range references: Typos in sheet names (e.g., "Sheet1" vs. "Sheet") or ranges (e.g., "A1:C10" vs. "A1:C100") will cause the macro to error. Use ws.Range("A1").CurrentRegion to dynamically capture all data.
  3. Attachment path errors: If the macro tries to save a file to a non-existent path (e.g., "C:\Temp"), it will crash. Always use ThisWorkbook.Path to ensure the file is saved in the same directory as the workbook.
  4. Ignoring Outlook’s macro security settings: Modern Outlook versions may block macros by default. Users must enable them via File > Options > Trust Center > Trust Center Settings > Macro Settings and select Enable all macros (not recommended for security-sensitive environments).
  5. Not testing with sample data: A macro that works with hardcoded values may fail when the worksheet updates. Always test with real data, especially if formulas or dynamic ranges are involved.

Tips

  • Use a template email: For consistency, save a pre-formatted email as a template (in Outlook’s New Items > Choose Form > User Templates) and modify the macro to open it instead of creating a new email.
  • Add error handling for email failures: Extend the macro to check if the email was sent successfully. Example:
        On Error Resume Next
        .Send 'Attempt to send
        If Err.Number <> 0 Then
            MsgBox "Failed to send email. Error: " & Err.Description, vbCritical
        End If
        On Error GoTo 0
        
  • Schedule the macro to run automatically: Use Excel’s VBA Editor > Alt+F8 > Macros > Options to set a shortcut key or assign it to a worksheet event (e.g., Worksheet_Change) for triggers like data entry.
  • Clean up temporary files: The macro creates a temporary Excel file. Add this after sending to delete it:
        Kill attachmentPath
        
  • Document your macro: Add comments in the VBA code (e.g., 'Change "recipient@example.com" to actual email) so others (or your future self) can update it easily.

Troubleshooting

If the macro runs but no email appears:

  1. Check Outlook’s Send/Receive settings:
    1. Open Outlook and go to Send/Receive > Send/Receive Groups > Define Send/Receive Groups.
    2. Ensure the default group is set to All Accounts or Online.
    3. Click Send/Receive > Send/Receive Now to force a sync.
  2. Verify the email account is configured correctly:
    1. In Outlook, go to File > Info > Account Settings.
    2. Check that the account is enabled and has a valid SMTP server.
    3. If using an exchange account, ensure offline mode is disabled (File > Info > Work Offline).
  3. Test with a simple email first:
        Set OutlookMail = OutlookApp.CreateItem(0)
        With OutlookMail
            .Subject = "Test Email"
            .Body = "This is a test."
            .Send 'Use .Display to preview instead of sending
        End With
        
    If this works, the issue is likely in your data or attachment code.

If you get "Object Required" errors:

  1. Ensure you’ve declared all objects with Dim (e.g., Dim OutlookMail As Object).
  2. Check for missing periods (.) in method calls (e.g., OutlookMail.Send instead of OutlookMail.Send()).
  3. Restart Excel and Outlook to clear any corrupted references.

If the attachment is corrupted:

  1. Replace the attachment code with:
        Dim attachmentPath As String
        attachmentPath = ThisWorkbook.Path & "\Report_" & Format(Now(), "yyyy_mm_dd") & ".xlsx"
        ThisWorkbook.Copy
        ActiveWorkbook.SaveAs attachmentPath, FileFormat:=xlOpenXMLWorkbook
        OutlookMail.Attachments.Add attachmentPath
        ActiveWorkbook.Close SaveChanges:=False
        
  2. Ensure the folder where the file is saved has write permissions.

If Outlook blocks the macro:

  1. Open Outlook and go to File > Options > Trust Center > Trust Center Settings > Macro Settings.
  2. Select Enable all macros (temporarily for testing).
  3. If security is a concern, use a Trust Centered approach by adding your workbook’s location to the trusted folder list.

Frequently Asked Questions

Can I send the email without Outlook installed?

No. The VBA method requires Outlook to be installed and configured on the same PC. Alternatives include using Excel’s Application.SendKeys to trigger an email client (risky and unreliable) or third-party add-ins like Redemption (commercial). For cloud-based solutions, consider Power Automate or Google Apps Script.

Will this work if the recipient’s email is in a different format (e.g., with a name like "John Doe <john@example.com>")?

Yes, but the macro must include the full email address. Outlook’s .To field only accepts valid email addresses. If you need to use display names, combine them like this:

.To = "John Doe "

Can I send the email as HTML or with formatting?

Yes. Modify the .Body to use HTML tags or add a formatted table:

.WithOutlookMail
    .Subject = "HTML Report"
    .HTMLBody = "

Monthly Sales

" & _ ws.Range("A1").CurrentRegion & "
" .Send End With
For full control over email formatting, open a template email in Outlook, copy its HTML, and paste it into the macro’s .HTMLBody.

How do I send the email as a BCC?

Use the .BCC property:

.WithOutlookMail
    .Subject = "BCC Report"
    .To = "manager@example.com" 'Primary recipient
    .BCC = "audit@example.com" 'Hidden recipient
    .Send
End With
Note: BCC recipients must be added via the .BCC property, not the .To field.

Will this work on a macro-enabled workbook shared with others?

No. Macros require the workbook to be opened with Enable Content in Excel’s security prompt. To share securely:

  1. Save the macro code in a separate workbook (e.g., MacrosOnly.xlsm).
  2. Use Application.Run to call the macro from the shared workbook:
        Application.Run "MacrosOnly.xlsm!SendEmailWithExcelData"
        
  3. Distribute the shared workbook as .xlsx (disable macros) and the macro workbook as .xlsm (require users to enable macros).

Can I schedule this macro to run daily?

Yes, but Excel’s VBA cannot natively schedule tasks. Use one of these methods:

  1. Windows Task Scheduler:
    1. Open Task Scheduler (search in Start Menu).
    2. Create a Basic Task to launch Excel with your workbook and press the macro’s shortcut key.
    3. Set the trigger to "Daily" at your preferred time.
  2. Excel’s built-in timer (less reliable): Use a worksheet event like Workbook_Open to trigger the macro after a delay (requires Application.OnTime).
For enterprise use, consider Power Automate or a dedicated scheduling tool.

What if the recipient’s email domain blocks automated messages?

Many corporate domains (e.g., Gmail, Outlook.com) flag automated emails as spam. To improve deliverability:

  1. Use a real, monitored email account (e.g., your work account) as the sender.
  2. Add a custom header to mimic a human sender (advanced; requires OutlookRedemption or CDO libraries).
        Dim objCDOMessage As Object
        Set objCDOMessage = CreateObject("CDO.Message")
        objCDOMessage.From = "Your Name "
        objCDOMessage.To = "recipient@example.com"
        '...
        
  3. Send a test email first to confirm the domain allows it.