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

Subscribe RSS
Follow me on TwitterTechnoratiYoutube VidsLinkedIn ProfileDelicious

    Recent Comments