Skip to main content

How to send email with multiple attachments attached in Excel?

Author Siluvia Last modified

This article is talking about sending an email through Outlook with multiple attachments attached in Excel.

Send email with multiple attachments attached in Excel with VBA code


Send email with multiple attachments attached in Excel with VBA code

Please do as follows to send an email with multiple attachments attached in Excel.

1. Please insert a command button by clicking Developer > Insert > Command Button (ActiveX Control). See screenshot:

click Command Button from Developer tab

2. After inserting the Command Button, please right click it and select View Code from the context menu.

select View Code from the context menu

3. In the opening Microsoft Visual Basic for Applications window, please click Tools > References as below screenshot shown.

click Tools > References

4. In the References – VBAProject dialog box, please find and check the Microsoft Outlook Object Library option, and then click the OK button.

check the Microsoft Outlook Object Library option in the dialog box

5. Then replace the original code in the Code window with below VBA code.

VBA code: Send email attached with multiple attachments in Excel

Private Sub CommandButton1_Click()
    Dim xStrFile As String
    Dim xFilePath As String
    Dim xFileDlg As FileDialog
    Dim xFileDlgItem As Variant
    Dim xOutApp As Outlook.Application
    Dim xMailOut As Outlook.MailItem
    Application.ScreenUpdating = False
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    Set xFileDlg = Application.FileDialog(msoFileDialogFilePicker)
    If xFileDlg.Show = -1 Then
        With xMailOut
            .BodyFormat = olFormatRichText
            .To = "happy.xuebi@163.com"
            .Subject = "test"
            .HTMLBody = "test"
            For Each xFileDlgItem In xFileDlg.SelectedItems
                .Attachments.Add xFileDlgItem
            Next xFileDlgItem
            .Display
        End With
    End If
    Set xMailOut = Nothing
    Set xOutApp = Nothing
    Application.ScreenUpdating = True
End Sub

Note: please specify your email recipient, subject, and body by changing the variate in .To = happy.xuebi@163.com, .Subject = "test" and .HTMLBody = "test" lines in the code.

6. Press the Alt + Q keys together to exit the Microsoft Visual Basic for Applications window.

7. Click Developer > Design Mode to turn off the Design Mode. See screenshot:

Click Design Mode to turn off the Design Mode

8. Click the Command Button to run the code. In the popping up Browse window, select the files you need to attach in the email, and then click the OK button. See screenshot:

run code to select the files you need to attach in the email

9. Then an email is created with specified fields and attachments listed out. Please click the Send button to send it. See screenshot:

an email is created with specified fields and attachments listed out

Note: The VBA code is only working when you use Outlook as your email program.


Easily send email through Outlook based on fields of created mailing list in Excel:

The Send Emails utility of Kutools for Excel helps users sending email through Outlook based on created mailing list in Excel.
Download and try it now! (30-day free trail)

send email with attachments by kutools


Related articles:

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!