Ga naar hoofdinhoud

Hoe stuur ik een e-mail met meerdere bijlagen in Excel?

In dit artikel wordt gesproken over het verzenden van een e-mail via Outlook met meerdere bijlagen in Excel.

Stuur e-mail met meerdere bijlagen in Excel met VBA-code


Stuur e-mail met meerdere bijlagen in Excel met VBA-code

Ga als volgt te werk om een ​​e-mail met meerdere bijlagen in Excel te verzenden.

1. Voeg een commandoknop in door op te klikken Ontwikkelaar > Invoegen > Commandoknop (ActiveX-besturingselement). Zie screenshot:

2. Na het invoegen van de Command-knop, klik er met de rechtermuisknop op en selecteer Bekijk code vanuit het contextmenu.

3. In de opening Microsoft Visual Basic voor toepassingen venster, klik dan Tools > Referenties zoals hieronder getoond screenshot.

4. In de Referenties - VBAProject dialoogvenster, zoek en controleer het Microsoft Outlook-objectbibliotheek optie en klik vervolgens op het OK knop.

5. Vervang vervolgens de originele code in het codevenster door onderstaande VBA-code.

VBA-code: stuur een e-mail met meerdere bijlagen 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 = ""
            .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: specificeer uw e-mailontvanger, onderwerp en hoofdtekst door de variate in .Naar = , .Subject = "test" en .HTMLBody = "test" regels in de code.

6. druk de anders + Q toetsen samen om het Microsoft Visual Basic voor toepassingen venster.

7. klikken Ontwikkelaar > Ontwerpmodus om de ontwerpmodus uit te schakelen. Zie screenshot:

8. Klik op de Command-knop om de code uit te voeren. Bij het opduiken Blader selecteer de bestanden die u in de e-mail wilt bijvoegen en klik vervolgens op het OK knop. Zie screenshot:

9. Vervolgens wordt een e-mail gemaakt met gespecificeerde velden en bijlagen. Klik op het Verzenden knop om het te verzenden. Zie screenshot:

Note: De VBA-code werkt alleen als u Outlook als uw e-mailprogramma gebruikt.


Verzend eenvoudig e-mail via Outlook op basis van velden van gemaakte mailinglijst in Excel:

De Stuur emails nut van Kutools for Excel helpt gebruikers bij het verzenden van e-mail via Outlook op basis van de gemaakte mailinglijst in Excel.
Download en probeer het nu! (30 dagen gratis proefrit)



Gerelateerde artikelen:

Beste Office-productiviteitstools

🤖 Kutools AI-assistent: Een revolutie teweegbrengen in de data-analyse op basis van: Intelligente uitvoering   |  Genereer code  |  Aangepaste formules maken  |  Analyseer gegevens en genereer grafieken  |  Roep Kutools-functies aan...
Populaire functies: Zoek, markeer of identificeer duplicaten   |  Verwijder lege rijen   |  Combineer kolommen of cellen zonder gegevens te verliezen   |   Ronde zonder formule ...
Super opzoeken: Meerdere criteria VLookup    VLookup met meerdere waarden  |   VOpzoeken over meerdere bladen   |   Fuzzy opzoeken ....
Geavanceerde vervolgkeuzelijst: Maak snel een vervolgkeuzelijst   |  Afhankelijke vervolgkeuzelijst   |  Multi-select vervolgkeuzelijst ....
Kolom Beheerder: Voeg een specifiek aantal kolommen toe  |  Kolommen verplaatsen  |  Schakel de zichtbaarheidsstatus van verborgen kolommen in  |  Vergelijk bereiken en kolommen ...
Uitgelichte functies: Raster focus   |  Ontwerpweergave   |   Grote formulebalk    Werkmap- en bladbeheer   |  resource Library (Auto-tekst)   |  Datumkiezer   |  Combineer werkbladen   |  Cellen coderen/decoderen    Stuur e-mails per lijst   |  Super filter   |   Speciaal filter (filter vet/cursief/doorhalen...) ...
Top 15 gereedschapsets12 Tekst Tools (toe te voegen tekst, Tekens verwijderen, ...)   |   50+ tabel Types (Gantt Chart, ...)   |   40+ Praktisch Formules (Bereken leeftijd op basis van verjaardag, ...)   |   19 Invoeging Tools (QR-code invoegen, Afbeelding invoegen vanaf pad, ...)   |   12 Camper ombouw Tools (Getallen naar woorden, Currency Conversion, ...)   |   7 Samenvoegen en splitsen Tools (Geavanceerd Combineer rijen, Gespleten cellen, ...)   |   ... en meer

Geef uw Excel-vaardigheden een boost met Kutools voor Excel en ervaar efficiëntie als nooit tevoren. Kutools voor Excel biedt meer dan 300 geavanceerde functies om de productiviteit te verhogen en tijd te besparen.  Klik hier om de functie te krijgen die u het meest nodig heeft...

Omschrijving


Office-tabblad Brengt een interface met tabbladen naar Office en maakt uw werk veel gemakkelijker

  • Schakel bewerken en lezen met tabbladen in Word, Excel, PowerPoint in, Publisher, Access, Visio en Project.
  • Open en maak meerdere documenten in nieuwe tabbladen van hetzelfde venster in plaats van in nieuwe vensters.
  • Verhoogt uw productiviteit met 50% en vermindert honderden muisklikken voor u elke dag!
Comments (14)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
أريد إرسال بريد إلكتروني مع البريد أو hotmail مع CDO ولكن كل ما لدي فقط مع مرفق واحد ولكن أريد أن أرسل مع العديد من المرفقات يرجى إرسال لي عن طريق بريدي الإلكتروني الرمز أو ملف Excel
Rated 5 out of 5
This comment was minimized by the moderator on the site
Is het ook mogelijk om een filter te zetten op de selectie van de bijlagen, zodat er alleen pdf-bestanden aan de mail kunnen worden toegevoegd?
This comment was minimized by the moderator on the site
Hi Alex de Graaf,
The code directly calls the Microsoft's file selection window. This makes it easy for VBA users to select needed files.
This comment was minimized by the moderator on the site
Hi Crystal,
Yes, I do understand that. However, is it possible to restrict users to only select pdf-files?
This comment was minimized by the moderator on the site
Hi Crystal,

Yes, I understand that. However I want the users to only be able to select pdf-files.
Is this possible?
This comment was minimized by the moderator on the site
Hi Alex de Graaf,
The following VBA code lists only the PDF files in the Browse window. Please give it a try.

Private Sub CommandButton1_Click()
'Updated by Extendoffice 20220714
    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)
    xFileDlg.Filters.Add "PDF", "*.pdf", 1
xFileDlg.FilterIndex = 1
    If xFileDlg.Show = -1 Then
        With xMailOut
            .BodyFormat = olFormatRichText
            .To = ""
            .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
This comment was minimized by the moderator on the site
Hola,
Me gustaría saber como quedaría la macro si quisiera enviar en un mismo correo a varias personas o más y con varios ficheros o más.
Muchas gracias.
This comment was minimized by the moderator on the site
I 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.
This comment was minimized by the moderator on the site
Superb...... Works perfectly.
This comment was minimized by the moderator on the site
HI Team ....i am unable to see the attachment in mail so if i follow the your step...can you pls help
This comment was minimized by the moderator on the site
the above code works perfectly thanks!! but my email automatic signature seem to disappear with this code. any idea why?
This comment was minimized by the moderator on the site
What if multiple different user and different attachment to be send with different subject line.
This comment was minimized by the moderator on the site
What if above files are located in sub-folders? How to look for a file in folder and sub-folders?
This comment was minimized by the moderator on the site
I 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!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations