Making Attachment Name the Message Subject

See how to display automatically the name of an attachment as the subject of the message.

Last modified: 2016/11/25 | Accessed: 7.257  | #161
◀ Previous sample Next sample ▶
OLKeeper OLKeeper
OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails.

Paste the code into the 'ThisOutlookSession' module and restart Outlook. As soon as you add a new attachment to an email its name will be displayed as the subject of the message.

tip  How to add macros to Outlook
Private WithEvents Mail As Outlook.MailItem
Private WithEvents Inspectors As Outlook.Inspectors

Private Sub Application_Startup()
  Set Inspectors = Application.Inspectors
End Sub

Private Sub Inspectors_NewInspector(ByVal Inspector As Inspector)
  If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
    Set Mail = Inspector.CurrentItem
  End If
End Sub

Private Sub Mail_AttachmentAdd(ByVal Attachment As Attachment)
  Mail.Subject = Attachment.DisplayName
End Sub
Category-Manager Category-Manager
With Category-Manager you can group your Outlook categories, share them with other users, filter a folder by category, automatically categorize new emails, and more. You can use the Addin even for IMAP.
email  Send a message