This morning I ran across the following tweet from hillarief.
As I explained to Hillarie when I replied, there’s no simple way to do this as an item is attached, but it’s pretty easy to do it as the message is sent. Of course this requires a macro. All the macro does is check each outbound message for attachments. If it finds any, then it builds a list of attachment names and appends it to the beginning of the message. The macro ignores hidden attachments (e.g. embedded images). This solution should work for Outlook 2007 and later. Hillarie is using Outlook 2010, so this should satisfy her requirement.
- Open Outlook.
- Press + to open the Visual Basic Editor
- If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
- Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
- Click the diskette icon on the toolbar to save the changes
- Close the VB Editor
- Click File and select Options
- When the Outlook Options dialog appears click Trust Center then click the Trust Center Settings button
- Click Macro Settings
- Select either of the two bottom settings (i.e. Notifications for all macros or Enable all macros (not recommended; potentially dangerous code can run). The choice of which to choose is up to you. If you select Notifications, then you’ll be prompted at times to enable macros. If you pick Enable all then there’s a chance that a malicious macro could run. It’s a question of how much risk you’re willing to assume.
- Click Ok until the dialog-boxes have all closed
- Close Outlook
- Start Outlook. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run. Say yes.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim olkAtt As Outlook.Attachment, strLst As String If Item.Class = olMail Then For Each olkAtt In Item.Attachments If Not IsHiddenAttachment(olkAtt) Then strLst = strLst & olkAtt.DisplayName & vbCrLf End If Next If Len(strLst) > 0 Then Select Case Item.BodyFormat Case olFormatHTML Item.HTMLBody = "Attached:<br><br>" & Replace(strLst, vbCrLf, "<br>") & "<br><br>" & Item.HTMLBody Case Else Item.Body = "Attached:" & vbCrLf & vbCrLf & strLst & vbCrLf & vbCrLf & Item.Body End Select Item.Save End If End If End Sub Public Function IsHiddenAttachment(olkAtt As Outlook.Attachment) As Boolean ' Purpose: Determines if an attachment is a hidden attachment. ' Written: 7/12/2012 ' Author: David Lee ' Outlook: 2007 and later Const PR_ATTACH_CONTENT_ID = "http://schemas.microsoft.com/mapi/proptag/0x3712001E" Dim olkPA As Outlook.PropertyAccessor, varTemp As Variant On Error Resume Next Set olkPA = olkAtt.PropertyAccessor varTemp = olkPA.GetProperty(PR_ATTACH_CONTENT_ID) IsHiddenAttachment = (varTemp <> "") On Error GoTo 0 Set olkPA = Nothing End Function