Alert For Missing Subject And Attachment in Outlook

Posted by rajivvishwa On January - 12 - 2009

Subject line in a mail is a key for identifying and digging the required mails from the mail archives. So we have to be careful not to miss it at any chance but unfortunately we do miss by accident. Another possible mistake we do is to miss the attachments mentioned in the mail.

Outlook Subject Alert Screenshot

A script is added to our outlook client which automatically pops up the alert as shown below.

The following script can be embedded in Outlook so that we get an alert whenever we miss the subject or the attachments

Code

Private Sub Application_ItemSend(ByVal Item As Object, cancel As Boolean)
 
Dim strSubject As String
strSubject = Item.Subject
If Len(Trim(strSubject)) = 0 Then
    Prompt$ = "Subject is Empty. Are you sure you want to send the Mail?"
    If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Subject is Empty") = vbNo Then
            cancel = True
    End If
End If
 
Dim lngres As Long
If (InStr(1, UCase(Item.Body), "ATTACH") <> 0 Or InStr(1, UCase(Item.Body), "PFA") <> 0) Then
    If Item.Attachments.Count = 0 Then
        lngres = MsgBox("Attachment reference detected, but no files attached. Send anyway?", _
        vbYesNo + vbDefaultButton2 + vbQuestion, "No files Attached")
 
        If lngres = vbNo Then cancel = True
    End If
End If
 
End Sub

Installation

  1. Open Outlook and Alt-F11 to open Visual Basic Editor
  2. Copy this code to ThisOutlookSession
  • now, a happy Outlook user

    You could explain the installation a little more, for instance:
    When I opened the VB editor, I needed to click on “Microsoft Outlook Object” to reveal “ThisOutlookSession”; and then there were no windows open in which to paste the code. I had to go, View, Code (or press F7) to bring up a window.
    Then I pasted your great code, hit the Save button, and then go File, Close and Return to Microsoft Outlook.
    Great job though. Works exactly how it should, without installing any third party software. Why it’s not included as standard, I really don’t know. You would have thought Microsoft would be aware of the problem of forgetting to actually attach something when you mean to.

Subscribe RSS
Follow me on TwitterTechnoratiYoutube VidsLinkedIn ProfileDelicious