Poka-yoke Outlook with a macro to prevent missing attachments and empty subject lines.
I had a bad day last week. I forgot the subject in one e-mail and an attachment in another. Finally tired of feeling like an idiot (although, as a colleague of mine pointed out, If that’s the biggest problem I have . . .), I snooped around the internet and found two reminder macros. The first is an attachment reminder, posted by Mark Bird, that pops-up when the word “attach” is in the e-mail body, but no attachment. The second is a subject reminder, posted at Gang’s Wavelength, that pops-up when the subject line is empty. I merged the two into one macro to do both. Here are the directions:
1. Go to Tools>Macro>security and make sure “Warnings for all macros” or “No security check for macros” is checked
2. Open your Outlook
3. Press Alt+F11. to open the Visual Basic editor.
4. Press Ctrl+R to open a Project.
5. On the Left Pane, expand the headings until you see “ThisOutLookSession”.
6. Double click on “ThisOutLookSession” to open code pane.
7. Copy and Paste the following code in the code pane and save it (all of the following text).
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim m As Variant
Dim strBody As String
Dim intIn As Long
Dim intAttachCount As Integer, intStandardAttachCount As Integer
On Error GoTo handleError
‘Edit the following line if you have a signature on your email that includes images or other files. Make intStandardAttachCount equal the number of files in your signature.
intStandardAttachCount = 0
strBody = LCase(Item.Body)
intIn = InStr(1, strBody, “original message”)
If intIn = 0 Then intIn = Len(strBody)
intIn = InStr(1, Left(strBody, intIn), “attach”)
intAttachCount = Item.Attachments.Count
If intIn > 0 And intAttachCount <= intStandardAttachCount Then
m = MsgBox(“It appears that you mean to send an attachment,” & vbCrLf & “but there is no attachment to this message.” & vbCrLf & vbCrLf & “Do you still want to send?”, vbQuestion + vbYesNo + vbMsgBoxSetForeground)
If m = vbNo Then Cancel = True
End If
handleError:
If Err.Number <> 0 Then
MsgBox “Outlook Attachment Reminder Error: ” & Err.Description, vbExclamation, “Outlook Attachment Reminder Error”
End If
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, “Check for Subject”) = vbNo Then
Cancel = True
End If
End If
End Sub
In: Uncategorized · Tagged with: Forgotten Attachment, No Subject, Outlook
