How to send email with multiple attachments attached in Excel?
This article is talking about sending an email through Outlook with multiple attachments attached in Excel.
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:
2. After inserting the Command Button, please right click it and 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.
4. In the References – VBAProject dialog box, please find and check the Microsoft Outlook Object Library option, and then click the OK button.
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 = "firstname.lastname@example.org" .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 = email@example.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:
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:
9. Then an email is created with specified fields and attachments listed out. Please click the Send button to send it. See screenshot:
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)
- How to send email to email addresses specified in cells in Excel?
- How to send email with copying and pasting a specified range into email body in Excel?
- How to insert signature into Outlook email when sending by vba in Excel?
- How to send email if due date has been met in Excel?
- How to automatically send email based on cell value in Excel?
You are guest
or post as a guest, but your post won't be published automatically.
To post as a guest, your comment is unpublished.· 3 months agoI have enjoyed working through this solution for adding multiple attachments to an email from within Excel VBA. Thank you. I know that a lot of us benefit and then want some aspect customized for exactly what we are trying to do. I am no different, but for step 8. Can we set the path that the Browse window will open with? I can browse over to another folder at a different location but if I could set the path that would be a time saver.
To post as a guest, your comment is unpublished.· 6 months agoSuperb...... Works perfectly.
To post as a guest, your comment is unpublished.· 1 years agoHI Team ....i am unable to see the attachment in mail so if i follow the your step...can you pls help
To post as a guest, your comment is unpublished.· 2 years agothe above code works perfectly thanks!! but my email automatic signature seem to disappear with this code. any idea why?
To post as a guest, your comment is unpublished.· 2 years agoWhat if multiple different user and different attachment to be send with different subject line.
To post as a guest, your comment is unpublished.· 2 years agoWhat if above files are located in sub-folders? How to look for a file in folder and sub-folders?
To post as a guest, your comment is unpublished.· 3 years agoI am able to "Quickly send email with multiple attachments attached in Excel with Kutools for Excel" using your steps above, but would like to take it one step further and personalize each email by inserting their names (from a column in the Excel sheet) into the body of the email. While in the body of the email, I try selecting the field and clicking on "Insert Placeholder" but nothing happens. Any idea why or how I can fix this? Thank you!