Direkt zum Inhalt

Wie fülle ich den E-Mail-Betreff automatisch mit dem Anhangsnamen in Outlook aus?

Für diejenigen, die es gewohnt sind, den Anhangsnamen als Betreff einer E-Mail in Outlook zu verwenden, ist es zeitaufwändig, den Anhangsnamen jedes Mal manuell in die Betreffzeile einzugeben. Wenn Sie die E-Mail-Betreffzeile automatisch mit dem Anhangsnamen füllen möchten, wenn Sie einen Anhang einfügen, wie im folgenden GIF gezeigt, hilft die VBA-Methode in diesem Tutorial.


Füllen Sie den E-Mail-Betreff automatisch mit dem Anhangsnamen mit VBA-Code aus

Bitte führen Sie den folgenden VBA-Code aus, um den E-Mail-Betreff automatisch mit dem Namen des eingefügten Anhangs in Outlook zu füllen.

1. Starten Sie Outlook und drücken Sie die Taste Andere + F11 Schlüssel zum Öffnen der Microsoft Visual Basic für Applikationen Fenster.

2. In dem Microsoft Visual Basic für Applikationen Fenster, Doppelklick Projekt1 (VbProjekt.OTM) > Microsoft Outlook-Objekte > DieseOutlookSession öffnen Diese Outlook-Sitzung (Code) Editor.

3. Kopieren Sie dann den folgenden VBA-Code in die Diese Outlook-Sitzung (Code) Editor.

VBA-Code: Füllen Sie den E-Mail-Betreff automatisch mit dem Namen des Anhangs aus

Public WithEvents GExplorer As Explorer
'Updated by Extendoffice 20220926
Public WithEvents GInspectors As Inspectors
Public WithEvents GMail As MailItem

Private Sub Application_Startup()
  Set GExplorer = Application.ActiveExplorer
  Set GInspectors = Application.Inspectors
End Sub

Private Sub GExplorer_InlineResponse(ByVal Item As Object)
  Set GMail = Item
End Sub

Private Sub GInspectors_NewInspector(ByVal Inspector As Inspector)
  Dim xItem As Object
  Set xItem = Inspector.CurrentItem
  If xItem.Class <> olMail Then Exit Sub
  Set GMail = xItem
End Sub

Private Sub GMail_AttachmentAdd(ByVal Att As Attachment)
  Dim xFileName As String
  On Error Resume Next
  If VBA.Trim(GMail.Subject) <> "" Then Exit Sub
  If MsgBox("Do you want to use the attachment name as the subject?", vbYesNo + vbInformation, "Kutools for Outlook") = vbNo Then Exit Sub
  xFileName = Att.DisplayName
  xFileName = Left$(xFileName, VBA.InStrRev(xFileName, ".") - 1)
  GMail.Subject = xFileName
End Sub

4. Jetzt müssen Sie den Code speichern und Outlook neu starten.

5. Wenn Sie von nun an einen Anhang in eine E-Mail einfügen, die noch keinen Betreff enthält, a Kutools for Outlook Es erscheint ein Dialogfeld, in dem Sie gefragt werden, ob Sie den Namen des Anhangs als Betreff verwenden möchten. Klicken Sie auf Ja .

Dann wird die Betreffzeile automatisch mit dem Namen des eingefügten Anhangs gefüllt.

Notizen:

1) Wenn Sie den Betreff bereits ausgefüllt haben, wird das Dialogfeld beim Einfügen eines Anhangs nicht angezeigt.
2) Wenn Sie einen bestehenden Betreff aus der aktuellen E-Mail entfernen, aber der Cursor immer noch in der Betreffzeile angezeigt wird, wird das Dialogfeld auch beim Einfügen eines Anhangs nicht angezeigt. Nachdem Sie den Betreff entfernt haben, müssen Sie außerhalb der Betreffzeile klicken, um das Meldungsfeld zu aktualisieren, damit der Code funktioniert.
3) Wenn Sie mehrere Anhänge gleichzeitig einfügen, kann nur der Name des ersten Anhangs als Betreff der E-Mail verwendet werden.

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 (11)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Everything works now. Thanks very much.
This comment was minimized by the moderator on the site
I'm glad I could help you.
This comment was minimized by the moderator on the site
Hello,
I pasted your code. Outlook 365 restarted. I've tried several times, but it doesn't work. The subject line remains empty. What could be the problem?
This comment was minimized by the moderator on the site
Hi Karol,

Please check if the corresponding Macro settings are enabled in your Outlook.
Go to File > Options. In the Outlook Options window, select Trust Center in the left pane. In the Trust Center window, select Macro Settings in the left pane, and then select the Enable all macros option in the Macro Settings section and check the Apply macro security settings to installed add-ins box in the Add-ins section.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/subject-auto.png
This comment was minimized by the moderator on the site
Добрый день. ДА при добавлении 2 файлов в тему писалось через И.
This comment was minimized by the moderator on the site
Hi Александр,

The following VBA code can help to solve your problem. Please give it a try.
Public WithEvents GExplorer As Explorer
'Updated by Extendoffice 20220131
Public WithEvents GInspectors As Inspectors
Public WithEvents GMail As MailItem
Dim GFileName As String

Private Sub Application_Startup()
  Set GExplorer = Application.ActiveExplorer
  Set GInspectors = Application.Inspectors
End Sub

Private Sub GExplorer_InlineResponse(ByVal Item As Object)
  Set GMail = Item
  GFileName = ""
End Sub

Private Sub GInspectors_NewInspector(ByVal Inspector As Inspector)
  Dim xItem As Object
  Set xItem = Inspector.CurrentItem
  If xItem.Class <> olMail Then Exit Sub
  Set GMail = xItem
  GFileName = ""
End Sub

Private Sub GMail_AttachmentAdd(ByVal Att As Attachment)
  If GMail.Subject = "" Then
    GMail.Subject = GFileName
  Else
    GMail.Subject = GMail.Subject & " AND " & GFileName
  End If
  GFileName = ""
End Sub

Private Sub GMail_BeforeAttachmentAdd(ByVal Attachment As Attachment, Cancel As Boolean)
  On Error Resume Next
  GFileName = Attachment.DisplayName
  GFileName = Left$(GFileName, VBA.InStrRev(GFileName, ".") - 1)
  If VBA.Trim(GMail.Subject) <> "" Then Exit Sub
  If MsgBox("Do you want to use the attachment name as the subject?", vbYesNo + vbInformation, "Kutools for Outlook") = vbNo Then
    GFileName = ""
    Exit Sub
  End If
End Sub
This comment was minimized by the moderator on the site
Да получилось. Огромное спасибо за помощь. И еще один вопрос, а можно в конце всего этого, при нажатии кнопки "Отправить" выдавал некое сообщение что то типа "Вы действительно хотите отправить данное сообщение"?
This comment was minimized by the moderator on the site
Да, именно. ТЕ при добавлении или перетягивании двух файлов тема письма автоматом писалась через И
This comment was minimized by the moderator on the site
Добрый день. Подскажите пожалуйста можно ли сделать что бы тема формировалась из 2 и более файлов с разделение И? Может в данном коде дописать или вообще другой существует? Заранее спасибо
This comment was minimized by the moderator on the site
Hi Александр,

Do you mean adding multiple attachments while adding those attachment names at the same time to the subject and then linking them with AND?
This comment was minimized by the moderator on the site
Да. Например перетащил два файла и он их имена написал через И. Именно два файла, больше не надо.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations