Loncat ke daftar isi utama

Bagaimana cara mencantumkan semua nama lampiran ke dalam badan pesan saat membuat email di Outlook?

Adakah cara yang baik bagi kami untuk memasukkan semua nama lampiran ke dalam badan pesan saat membuat email di Outlook? Artikel ini, saya akan berbicara tentang cara menyelesaikan pekerjaan ini di Outlook.

Cantumkan semua nama lampiran ke dalam badan pesan saat menulis email dengan kode VBA

Cantumkan semua nama lampiran ke dalam badan pesan saat membuat email dengan fitur sederhana


Cantumkan semua nama lampiran ke dalam badan pesan saat menulis email dengan kode VBA

Silakan lakukan dengan langkah-langkah berikut untuk menyelesaikan tugas ini:

1. Tahan ALT + F11 kunci untuk membuka Microsoft Visual Basic untuk Aplikasi jendela.

2. di Microsoft Visual Basic untuk Aplikasi jendela, klik dua kali Sesi Pandangan ini dari Project1 (VbaProject.OTM) panel untuk membuka mode, lalu salin dan tempel kode berikut ke dalam modul kosong.

Kode VBA: Cantumkan semua nama lampiran ke dalam badan pesan:

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. Lalu lanjutkan dengan mengklik Menyisipkan > Modul, salin dan tempel kode di bawah ini ke dalam modul kosong yang dibuka, lihat tangkapan layar:

Kode VBA: Cantumkan semua nama lampiran ke dalam badan pesan:

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. Dan kemudian klik Tools > Referensi dalam Microsoft Visual Basic untuk Aplikasi jendela, di muncul keluar Referensi-Proyek 1 kotak dialog, periksa Perpustakaan objek Microsoft Word pilihan dari Referensi yang Tersedia kotak daftar, lihat tangkapan layar:

5. Klik OK untuk keluar dari kotak dialog, maka Anda harus menambahkan tombol makro ke dalam Quick Access Toolbar. Di baru Sambutan dari Manajer Umum PT. LUHAI INDUSTRIAL jendela, pilih Lebih Banyak Perintah dari Sesuaikan Bilah Alat Akses Cepat drop down, lihat tangkapan layar:

6. di Pilihan Outlook kotak dialog, lakukan operasi berikut:

(1.) Pilih Macro dari Pilih perintah dari daftar drop-down;

(2.) Klik nama makro yang baru saja Anda sisipkan;

(3.) Lalu klik Add tombol untuk menambahkan makro ke dalam Sesuaikan Bilah Alat Akses Cepat.

7. Lalu klik OK untuk menutup kotak dialog, sekarang tombol makro telah dimasukkan ke dalam Quick Access Toolbar, lihat tangkapan layar:

8. Sekarang, ketika Anda membuat pesan baru, dan mengklik tombol makro, nama lampiran akan disisipkan di atas isi pesan seperti gambar berikut yang ditampilkan:


Cantumkan semua nama lampiran ke dalam badan pesan saat membuat email dengan fitur sederhana

Mungkin kode di atas agak sulit untuk Anda terapkan, jika sudah Kutools untuk Outlook, Dengan yang Salin Nama fitur ini, Anda dapat dengan cepat menyalin nama lampiran pesan dan menempelkannya di mana pun Anda membutuhkannya.

Catatan:Untuk menerapkan ini Salin Nama, pertama, Anda harus mengunduh Kutools untuk Outlook, lalu terapkan fitur dengan cepat dan mudah.

Setelah menginstal Kutools untuk Outlook, lakukan seperti ini:

1. Pertama, silahkan buat email baru yang Anda perlukan, lalu klik Kutools > Salin Nama di baru Sambutan dari Manajer Umum PT. LUHAI INDUSTRIAL jendela, lihat tangkapan layar:

2. Dan kemudian, kotak prompt akan muncul untuk mengingatkan Anda bahwa nama lampiran telah disalin ke clipboard, lihat tangkapan layar:

3. Sekarang, Anda hanya perlu menekan Ctrl + V kunci bersama-sama untuk menempelkan nama lampiran ke isi pesan yang Anda perlukan, lihat tangkapan layar:


Artikel yang lebih relatif:

  • Balas Semua Dengan Lampiran Asli Di Outlook
  • Biasanya, saat Anda menerapkan fungsi Balas Semua untuk membalas pesan ke semua penerima di Outlook, lampiran asli akan hilang secara otomatis. Apakah mungkin untuk melampirkan lampiran asli saat membalas ke semua di Outlook?
  • Unduh/Simpan Lampiran Dari Outlook Ke Folder Tertentu
  • Secara umum, Anda bisa menyimpan semua lampiran dari satu email dengan mengklik Lampiran> Simpan Semua Lampiran di Outlook. Tapi, jika Anda perlu menyimpan semua lampiran dari semua email yang diterima dan menerima email, idealnya? Artikel ini akan memperkenalkan dua solusi untuk mengunduh lampiran secara otomatis dari Outlook ke folder tertentu.
  • Ubah Lokasi Penyimpanan Lampiran Default Di Outlook
  • Pernahkah Anda muak menemukan lokasi lampiran yang telah Anda tentukan setiap kali meluncurkan Outlook? Dalam tutorial ini, kami akan menunjukkan cara mengubah lokasi lampiran default. Setelah itu, folder penyimpanan lampiran yang ditentukan akan dibuka secara otomatis setiap kali Anda menyimpan lampiran meskipun Anda memulai ulang Outlook.
  • Hapus Semua Lampiran Dari Email Di Outlook
  • Biasanya saat Anda melihat pratinjau email, Anda dapat menghapus lampiran dengan mengklik kanan dan memilih item Hapus Lampiran. Terkadang mungkin ada banyak lampiran dalam pesan email, dan akan membosankan jika menghapusnya satu per satu. Di sini kami memberi Anda dua trik mudah untuk menghapus semua lampiran dalam satu email, dan menghapus semua lampiran dari beberapa email juga di Outlook.

Alat Produktivitas Kantor Terbaik

Kutools untuk Outlook - Lebih dari 100 Fitur Canggih untuk Meningkatkan Outlook Anda

🤖 Asisten Surat AI: Email profesional instan dengan keajaiban AI--satu klik untuk mendapatkan balasan jenius, nada sempurna, penguasaan multibahasa. Ubah email dengan mudah! ...

📧 Email Otomatis: Di Luar Kantor (Tersedia untuk POP dan IMAP)  /  Jadwal Kirim Email  /  Auto CC/BCC Sesuai Aturan Saat Mengirim Email  /  Penerusan Otomatis (Aturan Lanjutan)   /  Tambah Salam Otomatis   /  Secara Otomatis Membagi Email Multi-Penerima menjadi Pesan Individual ...

📨 email Management: Mengingat Email dengan Mudah  /  Blokir Email Penipuan berdasarkan Subjek dan Lainnya  /  Hapus Email Duplikat  /  Pencarian  /  Konsolidasi Folder ...

📁 Lampiran ProPenyimpanan Batch  /  Pelepasan Batch  /  Kompres Batch  /  Penyimpanan otomatis   /  Lepaskan Otomatis  /  Kompres Otomatis ...

🌟 Antarmuka Ajaib: 😊Lebih Banyak Emoji Cantik dan Keren   /  Tingkatkan Produktivitas Outlook Anda dengan Tampilan Tab  /  Minimalkan Outlook Daripada Menutup ...

👍 Keajaiban sekali klik: Balas Semua dengan Lampiran Masuk  /   Email Anti-Phishing  /  🕘Tampilkan Zona Waktu Pengirim ...

👩🏼‍🤝‍👩🏻 Kontak & Kalender: Batch Tambahkan Kontak Dari Email yang Dipilih  /  Bagi Grup Kontak menjadi Grup Individual  /  Hapus Pengingat Ulang Tahun ...

Lebih 100 Fitur Tunggu Eksplorasi Anda! Klik Di Sini untuk Menemukan Lebih Banyak.

 

 

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