Skip i'r prif gynnwys

Sut i restru'r holl enwau atodiadau yn gorff negeseuon wrth gyfansoddi e-bost yn Outlook?

A oes unrhyw ffyrdd da inni fewnosod yr holl enwau atodiadau yn y corff negeseuon wrth gyfansoddi e-bost yn Outlook? Yr erthygl hon, byddaf yn siarad am sut i ddatrys y swydd hon yn Outlook.

Rhestrwch yr holl enwau atodiadau i gorff y neges wrth gyfansoddi e-bost gyda chod VBA

Rhestrwch yr holl enwau atodiadau i gorff y neges wrth gyfansoddi e-bost gyda nodwedd syml


Rhestrwch yr holl enwau atodiadau i gorff y neges wrth gyfansoddi e-bost gyda chod VBA

Gwnewch y camau canlynol i orffen y dasg hon:

1. Daliwch i lawr y ALT + F11 allweddi i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch ddwywaith SesiwnOutlook oddi wrth y Prosiect1 (VbaProject.OTM) cwarel i agor y modd, ac yna copïo a gludo'r cod canlynol i'r modiwl gwag.

Cod VBA: Rhestrwch yr holl enwau atodiadau yn y corff negeseuon:

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. Yna ewch ymlaen i glicio Mewnosod > Modiwlau, copïo a gludo islaw'r cod i'r modiwl gwag agored, gweler y screenshot:

Cod VBA: Rhestrwch yr holl enwau atodiadau yn y corff negeseuon:

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. Ac yna cliciwch offer > Cyfeiriadau yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, yn y popped allan Cyfeiriadau-Prosiect1 blwch deialog, gwirio Llyfrgell Gwrthrychau Microsoft Word opsiwn gan y Cyfeiriadau sydd ar Gael blwch rhestr, gweler y screenshot:

5. Cliciwch OK i adael y blwch deialog, yna dylech ychwanegu'r botwm macro i mewn i'r Bar Offer Mynediad Cyflym. Yn y newydd Neges ffenestr, dewiswch Mwy o Orchmynion oddi wrth y Addasu Bar Offer Mynediad Cyflym gwympo, gweler y screenshot:

6. Yn y Dewisiadau Outlook blwch deialog, gwnewch y gweithrediadau canlynol:

(1.) Dewis Macros oddi wrth y Dewiswch orchmynion oddi wrth rhestr ostwng;

(2.) Cliciwch yr enw macro rydych wedi'i fewnosod dim ond nawr;

(3.) Ac yna cliciwch Ychwanegu botwm i ychwanegu'r macro i mewn i'r Addasu Bar Offer Mynediad Cyflym.

7. Yna cliciwch OK i gau'r blwch deialog, nawr, mae'r botwm macro wedi'i fewnosod yn y Bar Offer Mynediad Cyflym, gweler y screenshot:

8. Nawr, pan fyddwch chi'n creu neges newydd, ac yn clicio ar y botwm macro, bydd enwau'r atodiadau yn cael eu mewnosod uwchben y corff negeseuon fel y dangosir y llun a ganlyn:


Rhestrwch yr holl enwau atodiadau i gorff y neges wrth gyfansoddi e-bost gyda nodwedd syml

Efallai bod y cod uchod mor anodd i chi wneud cais, os oes gennych chi Kutools ar gyfer Rhagolwg, Gyda'i Copi Enwau nodwedd, gallwch chi gopïo enwau atodiad neges yn gyflym a'u pastio yn unrhyw le rydych chi ei angen.

Nodyn:I gymhwyso hyn Copi Enwau, yn gyntaf, dylech lawrlwytho'r Kutools ar gyfer Rhagolwg, ac yna cymhwyswch y nodwedd yn gyflym ac yn hawdd.

Ar ôl gosod Kutools ar gyfer Rhagolwg, gwnewch fel hyn:

1. Yn gyntaf, crewch yr e-bost newydd sydd ei angen arnoch chi, ac yna cliciwch Kutools > Copi Enwau yn y newydd Neges ffenestr, gweler y screenshot:

2. Ac yna, bydd blwch prydlon yn popio allan i'ch atgoffa bod enwau'r atodiadau wedi'u copïo i'r clipfwrdd, gweler y screenshot:

3. Nawr, does ond angen pwyso Ctrl + V allweddi gyda'i gilydd i gludo'r enwau atodiadau i'r corff neges sydd ei angen arnoch, gweler y screenshot:


Erthyglau mwy cymharol:

  • Ateb Pawb Gyda Atodiadau Gwreiddiol Mewn Rhagolwg
  • Fel rheol, pan ddefnyddiwch y swyddogaeth Ateb Pawb i ateb y neges i'r holl dderbynwyr yn Outlook, collir yr atodiadau gwreiddiol yn awtomatig. A yw'n bosibl atodi atodiadau gwreiddiol wrth ateb pawb yn Outlook?
  • Dadlwythwch / Cadwch Atodiadau O Rhagolwg I Ffolder Penodol
  • A siarad yn gyffredinol, gallwch arbed pob atodiad o un e-bost trwy glicio Atodiadau> Cadw Pob Atodiad yn Outlook. Ond, os oes angen i chi arbed pob atodiad o'r holl negeseuon e-bost a dderbynnir a derbyn e-byst, unrhyw ddelfrydol? Bydd yr erthygl hon yn cyflwyno dau ddatrysiad i lawrlwytho atodiadau o Outlook yn awtomatig i ffolder benodol.
  • Newid Lleoliad Arbed Ymlyniad Rhagosodedig yn Rhagolwg
  • Ydych chi wedi cael llond bol ar ddod o hyd i leoliad yr atodiad rydych chi wedi'i nodi bob tro wrth lansio Outlook? Yn y tiwtorial hwn, byddwn yn dangos i chi sut i newid lleoliad yr atodiad diofyn. Ar ôl hynny, bydd y ffolder arbed atodiadau penodedig yn cael ei agor yn awtomatig bob tro y byddwch chi'n arbed yr atodiadau er eich bod chi'n ailgychwyn yr Outlook.
  • Tynnwch yr Holl Atodiadau O E-bost Mewn Rhagolwg
  • Fel rheol pan fyddwch yn rhagolwg e-bost, gallwch ddileu atodiad gyda chlicio ar y dde a dewis yr eitem Dileu Ymlyniad. Weithiau gall fod llawer o atodiadau mewn neges e-bost, a bydd yn ddiflas eu tynnu fesul un. Yma rydym yn eich trefnu gyda dau dric hawdd i gael gwared ar yr holl atodiadau mewn un e-bost, a thynnu pob atodiad o sawl e-bost hefyd yn Outlook.

Offer Cynhyrchiant Swyddfa Gorau

Kutools ar gyfer Rhagolwg - Dros 100 o Nodweddion Pwerus i Werthu Eich Outlook

🤖 Cynorthwy-ydd Post AI: E-byst pro ar unwaith gyda hud AI - un clic i atebion athrylith, tôn berffaith, meistrolaeth amlieithog. Trawsnewid e-bostio yn ddiymdrech! ...

📧 E-bostio Automation: Allan o'r Swyddfa (Ar gael ar gyfer POP ac IMAP)  /  Amserlen Anfon E-byst  /  Auto CC/BCC gan Reolau Wrth Anfon E-bost  /  Awto Ymlaen (Rheolau Uwch)   /  Auto Ychwanegu Cyfarchiad   /  Rhannwch E-byst Aml-Dderbynnydd yn Negeseuon Unigol yn Awtomatig ...

📨 Rheoli E-bost: Dwyn i gof E-byst yn Hawdd  /  Rhwystro E-byst Sgam gan Bynciau ac Eraill  /  Dileu E-byst Dyblyg  /  Chwilio Manwl  /  Cydgrynhoi Ffolderi ...

📁 Ymlyniadau ProArbed Swp  /  Swp Datgysylltu  /  Cywasgu Swp  /  Auto Achub   /  Datgysylltiad Auto  /  Cywasgiad Auto ...

🌟 Rhyngwyneb Hud: 😊Mwy o Emojis Pretty a Cŵl   /  Rhowch hwb i'ch Cynhyrchiant Outlook gyda Golygfeydd Tabbed  /  Lleihau Outlook Yn lle Cau ...

???? Rhyfeddodau un clic: Ateb Pawb ag Ymlyniadau Dod i Mewn  /   E-byst Gwrth-Gwe-rwydo  /  🕘Dangos Parth Amser yr Anfonwr ...

👩🏼‍🤝‍👩🏻 Cysylltiadau a Chalendr: Swp Ychwanegu Cysylltiadau O E-byst Dethol  /  Rhannwch Grŵp Cyswllt i Grwpiau Unigol  /  Dileu Atgoffa Pen-blwydd ...

Dros Nodweddion 100 Aros Eich Archwiliad! Cliciwch Yma i Ddarganfod Mwy.

 

 

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