Direkt zum Inhalt

Wie liste ich alle Anhangsnamen im Nachrichtentext auf, wenn ich E-Mails in Outlook verfasse?

Gibt es gute Möglichkeiten, beim Erstellen einer E-Mail in Outlook alle Anhangsnamen in den Nachrichtentext einzufügen? In diesem Artikel werde ich darüber sprechen, wie dieser Job in Outlook gelöst werden kann.

Listen Sie alle Anhangsnamen im Nachrichtentext auf, wenn Sie E-Mails mit VBA-Code verfassen

Listen Sie alle Anhangsnamen im Nachrichtentext auf, wenn Sie E-Mails mit einer einfachen Funktion erstellen


Listen Sie alle Anhangsnamen im Nachrichtentext auf, wenn Sie E-Mails mit VBA-Code verfassen

Führen Sie die folgenden Schritte aus, um diese Aufgabe abzuschließen:

1. Halten Sie die Taste gedrückt ALT + F11 Schlüssel zum Öffnen der Microsoft Visual Basic für Applikationen Fenster.

2. In dem Microsoft Visual Basic für Applikationen Fenster, Doppelklick DieseOutlookSession von dem Projekt1 (VbaProject.OTM) Bereich, um den Modus zu öffnen, und kopieren Sie dann den folgenden Code und fügen Sie ihn in das leere Modul ein.

VBA-Code: Listen Sie alle Anhangsnamen im Nachrichtentext auf:

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. Dann klicken Sie weiter Insert > Modul, kopieren Sie den folgenden Code und fügen Sie ihn in das geöffnete leere Modul ein, siehe Screenshot:

VBA-Code: Listen Sie alle Anhangsnamen im Nachrichtentext auf:

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. Und dann klick Tools > Bibliographie der Microsoft Visual Basic für Applikationen Fenster, in dem heraussprang Referenzen-Projekt1 Dialogfeld überprüfen Microsoft Word-Objektbibliothek Option von der Verfügbare Referenzen Listenfeld, siehe Screenshot:

5. Klicken Sie OK Um das Dialogfeld zu verlassen, sollten Sie die Makroschaltfläche hinzufügen Quick Access Toolbar. Im neuen Nachricht Fenster, wählen Sie Mehr Befehle von dem Anpassen der Symbolleiste für den Schnellzugriff Dropdown, siehe Screenshot:

6. In dem Outlook-Optionen Führen Sie im Dialogfeld die folgenden Vorgänge aus:

(1.) Wählen Sie Makros von dem Wählen Sie Befehle aus Dropdown-Liste;

(2.) Klicken Sie auf den Makronamen, den Sie gerade eingefügt haben;

(3.) Und dann klicken Speichern Klicken Sie auf die Schaltfläche, um das Makro zum hinzuzufügen Anpassen der Symbolleiste für den Schnellzugriff.

7. Dann klick OK Um das Dialogfeld zu schließen, wurde nun die Makroschaltfläche in das eingefügt Quick Access Toolbar, siehe Screenshot:

8. Wenn Sie nun eine neue Nachricht erstellen und auf die Makroschaltfläche klicken, werden die Anhangsnamen über dem Nachrichtentext eingefügt, wie im folgenden Screenshot gezeigt:


Listen Sie alle Anhangsnamen im Nachrichtentext auf, wenn Sie E-Mails mit einer einfachen Funktion erstellen

Möglicherweise ist die Anwendung des obigen Codes für Sie etwas schwierig, wenn Sie dies getan haben Kutools for OutlookMit seinen Namen kopieren Mit dieser Funktion können Sie die Anhangsnamen einer Nachricht schnell kopieren und an einer beliebigen Stelle einfügen.

Hinweis:Um dies anzuwenden Namen kopierenZunächst sollten Sie die herunterladen Kutools for Outlookund wenden Sie die Funktion dann schnell und einfach an.

Nach der Installation Kutools for OutlookBitte machen Sie Folgendes:

1. Bitte erstellen Sie zunächst die neue E-Mail, die Sie benötigen, und klicken Sie dann auf Kutoolen > Namen kopieren im neuen Nachricht Fenster, siehe Screenshot:

2. Und dann erscheint ein Eingabeaufforderungsfeld, das Sie daran erinnert, dass die Anhangsnamen in die Zwischenablage kopiert wurden, siehe Screenshot:

3. Jetzt müssen Sie nur noch drücken Strg + V Tasten zusammen, um die Anhangsnamen in den gewünschten Nachrichtentext einzufügen, siehe Screenshot:


Weitere relative Artikel:

  • Allen mit Originalanhängen in Outlook antworten
  • Wenn Sie die Funktion "Allen antworten" anwenden, um die Nachricht an alle Empfänger in Outlook zu beantworten, gehen normalerweise die ursprünglichen Anhänge automatisch verloren. Ist es möglich, Originalanhänge anzuhängen, wenn Sie in Outlook auf alle antworten?
  • Anhänge aus Outlook in einen bestimmten Ordner herunterladen/speichern
  • Im Allgemeinen können Sie alle Anhänge einer E-Mail speichern, indem Sie in Outlook auf Anhänge> Alle Anhänge speichern klicken. Aber wenn Sie alle Anhänge aus allen empfangenen und empfangenen E-Mails speichern müssen, ist dies ideal? In diesem Artikel werden zwei Lösungen vorgestellt, mit denen Anhänge automatisch aus Outlook in einen bestimmten Ordner heruntergeladen werden können.
  • Ändern des Speicherorts für Standardanhänge in Outlook
  • Haben Sie es satt, den Speicherort für Anhänge zu finden, den Sie jedes Mal beim Starten von Outlook angegeben haben? In diesem Tutorial zeigen wir Ihnen, wie Sie den Standardspeicherort für Anhänge ändern. Danach wird der angegebene Ordner zum Speichern von Anhängen jedes Mal automatisch geöffnet, wenn Sie die Anhänge speichern, obwohl Sie Outlook neu starten.
  • Entfernen Sie alle Anhänge aus E-Mails in Outlook
  • Normalerweise können Sie bei der Vorschau einer E-Mail einen Anhang löschen, indem Sie mit der rechten Maustaste klicken und das Element „Anhang entfernen“ auswählen. Manchmal enthält eine E-Mail-Nachricht viele Anhänge, und es ist mühsam, sie einzeln zu entfernen. Hier stellen wir Ihnen zwei einfache Tricks vor, mit denen Sie alle Anhänge in einer E-Mail und alle Anhänge aus mehreren E-Mails auch in Outlook entfernen können.

Beste Office-Produktivitätstools

Kutools for Outlook - Über 100 leistungsstarke Funktionen zur Optimierung Ihres Outlooks

🤖 KI-Mail-Assistent: Sofortige Profi-E-Mails mit KI-Magie – geniale Antworten mit einem Klick, perfekter Ton, mehrsprachige Beherrschung. Verwandeln Sie den E-Mail-Versand mühelos! ...

📧 E-Mail Automation: Abwesenheit (verfügbar für POP und IMAP)  /  Planen Sie das Senden von E-Mails  /  Automatisches CC/BCC nach Regeln beim E-Mail-Versand  /  Automatische Weiterleitung (erweiterte Regeln)   /  Begrüßung automatisch hinzufügen   /  Teilen Sie E-Mails mit mehreren Empfängern automatisch in einzelne Nachrichten auf ...

📨 E-Mail-Management: E-Mails einfach abrufen  /  Blockieren Sie betrügerische E-Mails nach Betreff und anderen  /  Doppelte E-Mails löschen  /  Erweiterte Suche  /  Ordner konsolidieren ...

📁 Anhänge ProBatch speichern  /  Stapeltrennung  /  Stapelkomprimierung  /  Automatisches Speichern   /  Automatische Trennung  /  Automatische Komprimierung ...

???? Schnittstellenmagie: 😊Mehr hübsche und coole Emojis   /  Steigern Sie Ihre Outlook-Produktivität mit Registerkartenansichten  /  Ausblick minimieren statt schließen ...

👍 Wunder mit einem Klick: Allen mit eingehenden Anhängen antworten  /   Anti-Phishing-E-Mails  /  🕘Zeitzone des Absenders anzeigen ...

👩🏼‍🤝‍👩🏻 Kontakte und Kalender: Fügen Sie Kontakte aus ausgewählten E-Mails im Stapel hinzu  /  Teilen Sie eine Kontaktgruppe in einzelne Gruppen auf  /  Geburtstagserinnerungen entfernen ...

Auf über 100 Eigenschaften Warten Sie auf Ihre Erkundung! Klicken Sie hier, um mehr zu erfahren.

 

 

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