Share via

Email verzenden via VBA

Paul Vandeputte 20 Reputation points
2026-03-31T08:12:07.01+00:00

hoe programmeer je IN VBA met Excel om een bijlage te verzenden?

Microsoft 365 and Office | Microsoft Family Safety | For home | Windows
0 comments No comments

Answer accepted by question author
  1. Q&A Assist
    2026-03-31T08:12:17.9766667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Onderstaande VBA-code in Excel maakt een nieuw e‑mailbericht in Outlook en voegt een bestand als bijlage toe.

    Sub StuurMailMetBijlage()
        Dim OutlookApp As Object
        Dim OutlookMail As Object
        Dim PadNaarBestand As String
    
        ' Volledig pad naar de bijlage
        PadNaarBestand = "C:\Map\Bestand.pdf"
    
        ' Outlook starten
        Set OutlookApp = CreateObject("Outlook.Application")
        Set OutlookMail = OutlookApp.CreateItem(0)   ' 0 = olMailItem
    
        With OutlookMail
            .To = "******@voorbeeld.com"          ' ontvanger
            .CC = ""                            ' optioneel
            .BCC = ""                           ' optioneel
            .Subject = "Onderwerp van de mail"
            .Body = "Tekst van de e-mail." & vbCrLf & "Met vriendelijke groet," & vbCrLf & "Naam"
    
            ' Bijlage toevoegen
            .Attachments.Add PadNaarBestand
    
            ' Toon bericht (gebruik .Send om direct te verzenden)
            .Display
        End With
    
        Set OutlookMail = Nothing
        Set OutlookApp = Nothing
    End Sub
    

    Belangrijk:

    • Outlook moet op de pc geïnstalleerd en geconfigureerd zijn.
    • Pas PadNaarBestand, To, Subject en Body aan naar wens.
    • Gebruik .Display om eerst te controleren; vervang door .Send om direct te verzenden.

    References:

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Paul Vandeputte 20 Reputation points
    2026-04-01T11:09:14.5666667+00:00

    het is oke.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.