ไปยังเนื้อหาหลัก

จะแสดงชื่อไฟล์แนบทั้งหมดในเนื้อหาข้อความเมื่อเขียนอีเมลใน Outlook ได้อย่างไร

มีวิธีใดที่ดีสำหรับเราในการแทรกชื่อไฟล์แนบทั้งหมดลงในเนื้อหาข้อความเมื่อเขียนอีเมลใน Outlook? บทความนี้ฉันจะพูดถึงวิธีแก้งานนี้ใน Outlook

ระบุชื่อไฟล์แนบทั้งหมดในเนื้อหาข้อความเมื่อเขียนอีเมลด้วยรหัส VBA

ระบุชื่อไฟล์แนบทั้งหมดในเนื้อหาข้อความเมื่อเขียนอีเมลด้วยคุณสมบัติง่ายๆ


ระบุชื่อไฟล์แนบทั้งหมดในเนื้อหาข้อความเมื่อเขียนอีเมลด้วยรหัส VBA

โปรดทำตามขั้นตอนต่อไปนี้เพื่อทำงานนี้ให้เสร็จ:

1. กด ALT + F11 คีย์เพื่อเปิด Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่าง

2. ใน Microsoft Visual Basic สำหรับแอปพลิเคชัน ดับเบิลคลิก นี้OutlookSession จาก โครงการ 1 (VbaProject.O ™) บานหน้าต่างเพื่อเปิดโหมดจากนั้นคัดลอกและวางรหัสต่อไปนี้ลงในโมดูลเปล่า

รหัส VBA: แสดงชื่อไฟล์แนบทั้งหมดในเนื้อหาข้อความ:

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. จากนั้นไปที่คลิก สิ่งที่ใส่เข้าไป > โมดูลคัดลอกและวางโค้ดด้านล่างลงในโมดูลว่างที่เปิดดูภาพหน้าจอ:

รหัส VBA: แสดงชื่อไฟล์แนบทั้งหมดในเนื้อหาข้อความ:

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. จากนั้นคลิก เครื่องมือ > อ้างอิง ใน Microsoft Visual Basic สำหรับแอปพลิเคชัน ในหน้าต่างที่โผล่ออกมา เอกสารอ้างอิง - โครงการ 1 กล่องโต้ตอบตรวจสอบ ไลบรารีวัตถุ Microsoft Word ตัวเลือกจาก อ้างอิงที่มีอยู่ กล่องรายการดูภาพหน้าจอ:

5. คลิก OK เพื่อออกจากกล่องโต้ตอบ คุณควรเพิ่มปุ่มมาโครลงใน แถบเครื่องมือด่วน. ในรูปแบบใหม่ ระบุความประสงค์หรือขอข้อมูลเพิ่มเติม หน้าต่างให้เลือก คำสั่งเพิ่มเติม จาก ปรับแต่งแถบเครื่องมือด่วน แบบเลื่อนลงดูภาพหน้าจอ:

6. ใน ตัวเลือกของ outlook ไดอะล็อกบ็อกซ์ให้ดำเนินการดังต่อไปนี้:

(1. ) เลือก แมโคร จาก เลือกคำสั่งจาก รายการแบบหล่นลง

(2.) คลิกชื่อมาโครที่คุณใส่ไว้ตอนนี้

(3. ) จากนั้นคลิก เพิ่ม ปุ่มเพื่อเพิ่มแมโครลงใน ปรับแต่งแถบเครื่องมือด่วน.

7. จากนั้นคลิก OK เพื่อปิดกล่องโต้ตอบ ขณะนี้ปุ่มมาโครถูกแทรกลงในแล้ว แถบเครื่องมือด่วนดูภาพหน้าจอ:

8. ตอนนี้เมื่อคุณสร้างข้อความใหม่และคลิกปุ่มมาโคร ชื่อไฟล์แนบจะถูกแทรกไว้เหนือเนื้อหาข้อความดังภาพต่อไปนี้:


ระบุชื่อไฟล์แนบทั้งหมดในเนื้อหาข้อความเมื่อเขียนอีเมลด้วยคุณสมบัติง่ายๆ

อาจเป็นไปได้ว่าโค้ดข้างต้นอาจเป็นเรื่องยากสำหรับคุณที่จะสมัครถ้าคุณมี Kutools สำหรับ Outlookเดียวกันกับที่ คัดลอกชื่อ คุณสมบัตินี้ทำให้คุณสามารถคัดลอกชื่อไฟล์แนบของข้อความและวางได้ทุกที่ที่คุณต้องการ

หมายเหตุที่จะใช้สิ่งนี้ คัดลอกชื่อประการแรกคุณควรดาวน์โหลดไฟล์ Kutools สำหรับ Outlookแล้วใช้คุณสมบัตินี้อย่างรวดเร็วและง่ายดาย

หลังจากการติดตั้ง Kutools สำหรับ Outlookโปรดทำตามนี้:

1. ขั้นแรก โปรดสร้างอีเมลใหม่ที่คุณต้องการ จากนั้นจึงคลิก Kutools > คัดลอกชื่อ ในใหม่ ระบุความประสงค์หรือขอข้อมูลเพิ่มเติม หน้าต่างดูภาพหน้าจอ:

2. จากนั้นกล่องข้อความจะปรากฏขึ้นเพื่อเตือนให้คุณคัดลอกชื่อไฟล์แนบไปยังคลิปบอร์ดแล้ว ดูภาพหน้าจอ:

3. ตอนนี้คุณเพียงแค่ต้องกด Ctrl + V คีย์ร่วมกันเพื่อวางชื่อไฟล์แนบลงในเนื้อหาข้อความที่คุณต้องการ ดูภาพหน้าจอ:


บทความที่เกี่ยวข้องเพิ่มเติม:

  • ตอบกลับทั้งหมดด้วยไฟล์แนบต้นฉบับใน Outlook
  • โดยปกติเมื่อคุณใช้ฟังก์ชันตอบกลับทั้งหมดเพื่อตอบกลับข้อความไปยังผู้รับทั้งหมดใน Outlook ไฟล์แนบต้นฉบับจะหายไปโดยอัตโนมัติ เป็นไปได้ไหมที่จะแนบไฟล์แนบต้นฉบับเมื่อตอบกลับทั้งหมดใน Outlook
  • ดาวน์โหลด/บันทึกไฟล์แนบจาก Outlook ไปยังโฟลเดอร์บางโฟลเดอร์
  • โดยทั่วไปคุณสามารถบันทึกไฟล์แนบทั้งหมดของอีเมลเดียวโดยคลิกไฟล์แนบ> บันทึกไฟล์แนบทั้งหมดใน Outlook แต่ถ้าคุณต้องการบันทึกไฟล์แนบทั้งหมดจากอีเมลที่ได้รับและการรับอีเมลทั้งหมดจะเหมาะหรือไม่? บทความนี้จะแนะนำสองวิธีในการดาวน์โหลดไฟล์แนบจาก Outlook ไปยังโฟลเดอร์หนึ่งโดยอัตโนมัติ
  • เปลี่ยนตำแหน่งเริ่มต้นการบันทึกไฟล์แนบใน Outlook
  • คุณเบื่อกับการค้นหาตำแหน่งไฟล์แนบที่คุณระบุทุกครั้งเมื่อเปิด Outlook หรือไม่? ในบทช่วยสอนนี้เราจะแสดงวิธีเปลี่ยนตำแหน่งไฟล์แนบเริ่มต้น หลังจากนั้นโฟลเดอร์บันทึกไฟล์แนบที่ระบุจะเปิดโดยอัตโนมัติทุกครั้งที่คุณบันทึกไฟล์แนบแม้ว่าคุณจะเริ่ม Outlook ใหม่
  • ลบไฟล์แนบทั้งหมดออกจากอีเมลใน Outlook
  • โดยปกติเมื่อคุณดูตัวอย่างอีเมล คุณสามารถลบไฟล์แนบได้ด้วยการคลิกขวาและเลือกรายการลบไฟล์แนบ บางครั้งอาจมีไฟล์แนบจำนวนมากในข้อความอีเมล และการลบออกทีละรายการอาจเป็นเรื่องที่น่าเบื่อ ที่นี่เราจัดเตรียมเคล็ดลับง่ายๆ สองข้อให้คุณเพื่อลบไฟล์แนบทั้งหมดในอีเมลเดียว และลบไฟล์แนบทั้งหมดออกจากอีเมลหลายฉบับรวมถึงใน Outlook

สุดยอดเครื่องมือเพิ่มผลผลิตในสำนักงาน

Kutools สำหรับ Outlook - คุณสมบัติอันทรงพลังมากกว่า 100 รายการเพื่อเติมพลังให้กับ Outlook ของคุณ

🤖 ผู้ช่วยจดหมาย AI: ส่งอีเมลระดับมืออาชีพทันทีด้วยเวทมนตร์ AI คลิกเพียงครั้งเดียวเพื่อตอบกลับอย่างชาญฉลาด น้ำเสียงที่สมบูรณ์แบบ การเรียนรู้หลายภาษา เปลี่ยนรูปแบบการส่งอีเมลอย่างง่ายดาย! ...

📧 การทำงานอัตโนมัติของอีเมล: ไม่อยู่ที่สำนักงาน (ใช้ได้กับ POP และ IMAP)  /  กำหนดการส่งอีเมล  /  Auto CC/BCC ตามกฎเมื่อส่งอีเมล  /  ส่งต่ออัตโนมัติ (กฎขั้นสูง)   /  เพิ่มคำทักทายอัตโนมัติ   /  แบ่งอีเมลผู้รับหลายรายออกเป็นข้อความส่วนตัวโดยอัตโนมัติ ...

📨 การจัดการอีเมล์: เรียกคืนอีเมลได้อย่างง่ายดาย  /  บล็อกอีเมลหลอกลวงตามหัวเรื่องและอื่นๆ  /  ลบอีเมลที่ซ้ำกัน  /  การค้นหาขั้นสูง  /  รวมโฟลเดอร์ ...

📁 ไฟล์แนบโปรบันทึกแบทช์  /  การแยกแบทช์  /  การบีบอัดแบบแบตช์  /  บันทึกอัตโนมัติ   /  ถอดอัตโนมัติ  /  บีบอัดอัตโนมัติ ...

🌟 อินเตอร์เฟซเมจิก: 😊อีโมจิที่สวยและเจ๋งยิ่งขึ้น   /  เพิ่มประสิทธิภาพการทำงาน Outlook ของคุณด้วยมุมมองแบบแท็บ  /  ลดขนาด Outlook แทนที่จะปิด ...

???? เพียงคลิกเดียวสิ่งมหัศจรรย์: ตอบกลับทั้งหมดด้วยไฟล์แนบที่เข้ามา  /   อีเมลต่อต้านฟิชชิ่ง  /  🕘 แสดงโซนเวลาของผู้ส่ง ...

👩🏼‍🤝‍👩🏻 รายชื่อและปฏิทิน: แบทช์เพิ่มผู้ติดต่อจากอีเมลที่เลือก  /  แบ่งกลุ่มผู้ติดต่อเป็นกลุ่มแต่ละกลุ่ม  /  ลบการแจ้งเตือนวันเกิด ...

เกิน คุณสมบัติ 100 รอการสำรวจของคุณ! คลิกที่นี่เพื่อค้นพบเพิ่มเติม

 

 

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