VBOffice

Display Number of Attachments

You can see in the inbox whether or not an email has attachments. However, you cannot see the amount of attachments. This macro adds that information to every incoming email.

Last modified: 2015/06/06 | Accessed: 33.186  | #148
◀ Previous sample Next sample ▶
ReplyAll ReplyAll
ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.

Paste the code to the ThisOutlookSession module, then restart Outlook. After the first email was received while the macro was running, you can add the new property 'NumberAttachments' to the folder view (View Settings/Columns).


tip  How to add macros to Outlook
Private WithEvents m_Items As Outlook.Items

Private Sub Application_Startup()
  Set m_Items = Application.Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub m_Items_ItemAdd(ByVal Item As Object)
  Dim Atts As Outlook.Attachments
  Dim Props As Outlook.UserProperties
  Dim Prop As Outlook.UserProperty
  Dim PropName As String
  
  PropName = "NumberAttachments"
  
  Set Atts = Item.Attachments
  Set Props = Item.UserProperties
  Set Prop = Props.Find(PropName, True)
  If Prop Is Nothing Then
    Set Prop = Props.Add(PropName, olText, True)
  End If
  Prop.Value = Atts.Count
  Item.Save
End Sub
Reporter Reporter
VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.
email  Send a message