Ga naar hoofdinhoud

Hoe alle bijlagenamen in de berichttekst vermelden bij het opstellen van e-mail in Outlook?

Zijn er goede manieren om alle bijlagenamen in de berichttekst in te voegen bij het opstellen van een e-mail in Outlook? In dit artikel zal ik het hebben over het oplossen van deze taak in Outlook.

Maak een lijst van alle bijlagenamen in de berichttekst bij het opstellen van e-mail met VBA-code

Maak een lijst van alle bijlagenamen in de berichttekst bij het opstellen van een e-mail met een eenvoudige functie


Maak een lijst van alle bijlagenamen in de berichttekst bij het opstellen van e-mail met VBA-code

Voer de volgende stappen uit om deze taak te voltooien:

1. Houd de ALT + F11 toetsen om de te openen Microsoft Visual Basic voor toepassingen venster.

2. In de Microsoft Visual Basic voor toepassingen venster, dubbelklik DezeOutlookSessie van het Project1 (VbaProject.OTM) deelvenster om de modus te openen en kopieer en plak vervolgens de volgende code in de lege module.

VBA-code: vermeld alle bijlagenamen in de berichttekst:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim xMailItem As MailItem
    If Item.Class = olMail Then
        Set xMailItem = Item
        If xMailItem.Attachments.Count > 0 Then
          AddAttachmentNamesToBody
        End If
    End If
    End Sub

3. Blijf dan klikken Invoegen > Module, kopieer en plak onderstaande code in de geopende lege module, zie screenshot:

VBA-code: vermeld alle bijlagenamen in de berichttekst:

Public Sub AddAttachmentNamesToBody()
    Dim xMailItem As MailItem
    Dim xAttachment As Attachment
    Dim xFileName As String
   Dim xInspector As Outlook.Inspector
    Dim xDoc As Word.Document
    Dim xWdSelection As Word.Selection
    On Error Resume Next
    Set xMailItem = Outlook.ActiveInspector.CurrentItem
    If xMailItem.Attachments.Count = 0 Then
        Exit Sub
    End If
    xFileName = ""
    For Each xAttachment In xMailItem.Attachments
        If xFileName = "" Then
            xFileName = " <" & xAttachment.FileName & "> "
        Else
            xFileName = xFileName & vbCrLf & " <" & xAttachment.FileName & "> "
        End If
    Next xAttachment
    Set xInspector = Outlook.Application.ActiveInspector()
    Set xDoc = xInspector.WordEditor
    Set xWdSelection = xDoc.Application.Selection
    xWdSelection.HomeKey Unit:=wdStory
    xWdSelection.InsertBefore "Attachments: " & vbCrLf & xFileName & vbCrLf & vbCrLf
    Set xMailItem = Nothing
    End Sub

4. En klik vervolgens op Tools > Referenties in de Microsoft Visual Basic voor toepassingen raam, in de pop uit Referenties-Project1 dialoogvenster, vink aan Microsoft Word-objectbibliotheek optie van de Beschikbare referenties keuzelijst, zie screenshot:

5. Klikken OK Om het dialoogvenster te verlaten, moet u de macroknop toevoegen aan het Snelle toegangswerkbalk. In het nieuwe Bericht venster, kies Meer opdrachten van het Pas de werkbalk Snelle toegang aan dropdown, zie screenshot:

6. In de Outlook Opties dialoogvenster voert u de volgende bewerkingen uit:

(1.) Selecteer Macro's van het Kies opdrachten van keuzelijst;

(2.) Klik op de macronaam die u zojuist hebt ingevoegd;

(3.) En klik dan Toevoegen knop om de macro toe te voegen aan het Pas de werkbalk Snelle toegang aan.

7. Dan klikken OK om het dialoogvenster te sluiten, is nu de macroknop ingevoegd in het Snelle toegangswerkbalk, zie screenshot:

8. Wanneer u nu een nieuw bericht maakt en op de macroknop klikt, worden de namen van de bijlagen boven de berichttekst ingevoegd, zoals in de onderstaande schermafbeelding:


Maak een lijst van alle bijlagenamen in de berichttekst bij het opstellen van een e-mail met een eenvoudige functie

Het kan zijn dat de bovenstaande code enigszins moeilijk voor u is om toe te passen, als u dat al heeft gedaan Kutools for Outlook, Met Kopieer namen Met deze functie kunt u snel de namen van de bijlagen van een bericht kopiëren en deze overal plakken waar u maar wilt.

Opmerking:Om dit toe te passen Kopieer namen, ten eerste moet u het Kutools for Outlooken pas de functie vervolgens snel en gemakkelijk toe.

Na het installeren van Kutools for Outlook, doe dit als volgt:

1. Maak eerst het nieuwe e-mailadres dat u nodig heeft en klik vervolgens op Kutools > Kopieer namen in het nieuwe Bericht venster, zie screenshot:

2. En dan verschijnt er een promptvenster om u eraan te herinneren dat de namen van de bijlagen naar het klembord zijn gekopieerd, zie screenshot:

3. Nu hoeft u alleen maar op te drukken Ctrl + V toetsen samen om de namen van de bijlagen in de berichttekst te plakken die u nodig hebt, zie screenshot:


Meer relatieve artikelen:

  • Beantwoord iedereen met originele bijlagen in Outlook
  • Normaal gesproken gaan de originele bijlagen automatisch verloren als u de functie Allen beantwoorden toepast om het bericht aan alle ontvangers in Outlook te beantwoorden. Is het mogelijk om originele bijlagen toe te voegen wanneer u iedereen beantwoordt in Outlook?
  • Download/bewaar bijlagen van Outlook naar een bepaalde map
  • Over het algemeen kunt u alle bijlagen van één e-mail opslaan door te klikken op Bijlagen> Alle bijlagen opslaan in Outlook. Maar als u alle bijlagen van alle ontvangen e-mails en ontvangen e-mails wilt opslaan, een ideaal dan? Dit artikel introduceert twee oplossingen om automatisch bijlagen van Outlook naar een bepaalde map te downloaden.
  • Wijzig de standaardlocatie voor het opslaan van bijlagen in Outlook
  • Ben je het zat om de bijlagelocatie te vinden die je hebt opgegeven telkens wanneer je Outlook start? In deze zelfstudie laten we u zien hoe u de standaardlocatie voor bijlagen kunt wijzigen. Daarna wordt de opgegeven map voor het opslaan van bijlagen automatisch geopend telkens wanneer u de bijlagen opslaat, ook al start u Outlook opnieuw op.
  • Verwijder alle bijlagen uit e-mail in Outlook
  • Normaal gesproken kunt u, wanneer u een voorbeeld van een e-mail bekijkt, een bijlage verwijderen door met de rechtermuisknop te klikken en het item Bijlage verwijderen te selecteren. Soms kunnen er veel bijlagen in een e-mailbericht voorkomen en zal het vervelend zijn om ze één voor één te verwijderen. Hier geven we u twee eenvoudige trucs om alle bijlagen in één e-mail te verwijderen, en ook alle bijlagen uit meerdere e-mails in Outlook.

Beste Office-productiviteitstools

Kutools for Outlook - Meer dan 100 krachtige functies om uw Outlook een boost te geven

🤖 AI Mail-assistent: Directe professionele e-mails met AI-magie: met één klik geniale antwoorden, perfecte toon, meertalige beheersing. Transformeer e-mailen moeiteloos! ...

???? Email Automation: Niet aanwezig (beschikbaar voor POP en IMAP)  /  Plan het verzenden van e-mails  /  Automatische CC/BCC volgens regels bij het verzenden van e-mail  /  Automatisch doorsturen (geavanceerde regels)   /  Begroeting automatisch toevoegen   /  Splits e-mails van meerdere ontvangers automatisch op in individuele berichten ...

📨 email management: Gemakkelijk e-mails herinneren  /  Blokkeer zwendel-e-mails van onderwerpen en anderen  /  Verwijder dubbele e-mails  /  Uitgebreid Zoeken  /  Consolideer mappen ...

📁 Bijlagen ProBatch opslaan  /  Batch losmaken  /  Batchcompressie  /  Automatisch opslaan   /  Automatisch loskoppelen  /  Automatisch comprimeren ...

???? Interface-magie: 😊Meer mooie en coole emoji's   /  Verhoog uw Outlook-productiviteit met weergaven met tabbladen  /  Minimaliseer Outlook in plaats van te sluiten ...

???? Wonderen met één klik: Beantwoord iedereen met inkomende bijlagen  /   Antiphishing-e-mails  /  🕘Toon de tijdzone van de afzender ...

👩🏼‍🤝‍👩🏻 Contacten en agenda: Batchcontacten toevoegen uit geselecteerde e-mails  /  Splits een contactgroep in individuele groepen  /  Verwijder verjaardagsherinneringen ...

Over 100 Eigenschappen Wacht op je verkenning! Klik hier om meer te ontdekken.

 

 

Comments (12)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Why am I getting "user-defined type not defined" when I get to Step 8?
This comment was minimized by the moderator on the site
Why am I getting "user-defined type not defined" when I get to Step 8?
This comment was minimized by the moderator on the site
When I do this, it always put the attachments at the beginning of the message, no matter where my cursor is located. I then have to copy/paste to the bottom of the email. Is there a way to change that?
This comment was minimized by the moderator on the site
Hello, VMS,
If you want to put the attachments at the the position of your cursor, please replace the second code with following code:

Public Sub AddAttachmentNamesToBody()

Dim xMailItem As MailItem

Dim xAttachment As Attachment

Dim xFileName As String

Dim xInspector As Outlook.Inspector

Dim xDoc As Word.Document

Dim xWdSelection As Word.Selection

On Error Resume Next

Set xMailItem = Outlook.ActiveInspector.CurrentItem

If xMailItem.Attachments.Count = 0 Then

Exit Sub

End If

xFileName = ""

For Each xAttachment In xMailItem.Attachments

If xFileName = "" Then

xFileName = " <" & xAttachment.FileName & "> "

Else

xFileName = xFileName & vbCrLf & " <" & xAttachment.FileName & "> "

End If

Next xAttachment

Set xInspector = Outlook.Application.ActiveInspector()

Set xDoc = xInspector.WordEditor

Set xWdSelection = xDoc.Application.Selection

xWdSelection.InsertBefore "Attachments: " & vbCrLf & xFileName & vbCrLf & vbCrLf

Set xMailItem = Nothing

End Sub

Please try, hope it can help you!
This comment was minimized by the moderator on the site
That worked! Now another favor... How do I exclude certain file types or names? My required company signature contains a PNG file that I would like to exclude.Thank you!!
This comment was minimized by the moderator on the site
To exclude some specific files, please apply the below code, please try it.
Public Sub AddAttachmentNamesToBody()

Dim xMailItem As MailItem

Dim xAttachment As Attachment

Dim xFileName As String

Dim xInspector As Outlook.Inspector

Dim xDoc As Word.Document

Dim xWdSelection As Word.Selection

Dim xExt As String

Dim xFound As Boolean

Dim xExtArr As Variant

On Error Resume Next

xExtArr = Array("docx", "exe") 'change the file extension you want to exclude

Set xMailItem = Outlook.ActiveInspector.CurrentItem

If xMailItem.Attachments.Count = 0 Then

Exit Sub

End If

xFileName = ""

For Each xAttachment In xMailItem.Attachments

xExt = VBA.Mid(xAttachment.FileName, VBA.InStrRev(xAttachment.FileName, ".") + 1)

xFound = False

For i = LBound(xExtArr) To UBound(xExtArr)

If xExt = xExtArr(i) Then

xFound = True

Exit For

End If

Next

If xFound = False Then

If xFileName = "" Then

xFileName = " <" & xAttachment.FileName & "> "

Else

xFileName = xFileName & vbCrLf & " <" & xAttachment.FileName & "> "

End If

End If

Next xAttachment

Set xInspector = Outlook.Application.ActiveInspector()

Set xDoc = xInspector.WordEditor

Set xWdSelection = xDoc.Application.Selection

xWdSelection.InsertBefore "Attachments: " & vbCrLf & xFileName & vbCrLf & vbCrLf

Set xMailItem = Nothing

End Sub
This comment was minimized by the moderator on the site
when I tried this code it sends the attachment names in every email that has attachments.
I want it to only do it when I click the macro.

How do I amend the code to do just that?
This comment was minimized by the moderator on the site
I also don't know how to fix it. Anyone could hep on that?
This comment was minimized by the moderator on the site
This is wonderful -- thank you! Is there also a way to somehow view all the attachment names in an email that has been sent to you from someone else (i.e. received)? For some reason, the file names are not displaying in full unless you hover, which is ridiculous when you regularly have 15 files to sort through.
This comment was minimized by the moderator on the site
Hello,
To List all attachment names in an received email, please copy and pase the below VBA code into the ThisOutlookSession module of the Microsoft Visual Basic for Applications window:

Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim xEIDArr As Variant, xEID As Variant, xItem As Object
Dim xAttachment As Attachment
Dim xFileName As String
On Error Resume Next
xEIDArr = Split(EntryIDCollection, ",")
For Each xEID In xEIDArr
Set xItem = Session.GetItemFromID(xEID)
If xItem.Class = olMail Then
xFileName = ""
For Each xAttachment In xItem.Attachments
If IsEmbeddedAttachment(xAttachment) = False Then
If xFileName = "" Then
xFileName = " " & "<" & xAttachment.FileName & ">"
Else
xFileName = xFileName & "
" & " " & "<" & xAttachment.FileName & ">"
End If
End If
Next xAttachment
If xFileName = "" Then Exit Sub
xFileName = "Attachments: " & "
" & xFileName & "
" & "
"
xItem.HTMLBody = "" & xFileName & "" & xItem.HTMLBody
xItem.Save
End If
Next
Set xItem = Nothing
End Sub

Function IsEmbeddedAttachment(Attach As Attachment)
Dim xAttParent As Object
Dim xCID As String, xID As String
Dim xHTML As String
On Error Resume Next
Set xAttParent = Attach.Parent
xCID = ""
xCID = Attach.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001F")
If xCID <> "" Then
xHTML = xAttParent.HTMLBody
xID = "cid:" & xCID
If InStr(xHTML, xID) > 0 Then
IsEmbeddedAttachment = True
Else
IsEmbeddedAttachment = False
End If
End If
End Function

After pasting this code, when new emails with attachments arriving in your Outlook, the attachment names will be listed at the top of the message body automatically.
Please try it, hope it can help you!
This comment was minimized by the moderator on the site
this is great. Is there any way to merge this with VMS's request above to exclude some specific files included in signatures (.png, .jpg, etc.)?
This comment was minimized by the moderator on the site
Great, thanks for that. I wonder if it is possible that the list of attachments is only attached when I write to a specific email address?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations