Forgetting Attachments
Originally posted 2005-07-11 13:56:45
Today, for the 4,256th time in my email career, I sent an email that promised an attachment but sallied forth with no files attached. After the recipient pointed out my mistake, I hastily resent the email with the proper file attached. Then I got to thinking: why don’t email clients detect this sort of behavior and protect us poor digital scribes from ourselves? This seems to be exactly the sort of thing that computers excel at. So, I launched Google and found this:
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=341
It’s a VBA macro that scours an outgoing message for \”attach\” or \”enclos,\” determines whether the email has attachments, and prompts me if I’ve flubbed. I changed the prompt a bit. Here’s my modified code:
Option Explicit Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) If Item.Class <> olMail Then Exit Sub If Item.Attachments.Count > 0 Then Exit Sub If Not SearchForAttachWords(Item.Subject & \":\" & Item.Body) Then Exit Sub If UserWantsToAttach Then ExecuteInsertFileCommand End If End Sub Function SearchForAttachWords(ByVal s As String) As Boolean Dim v As Variant For Each v In Array(\"attach\", \"enclos\") If InStr(1, s, v, vbTextCompare) <> 0 Then SearchForAttachWords = True Exit Function End If Next End Function Function UserWantsToAttach() As Boolean If MsgBox(\"Did you forget the attachment?\", vbQuestion + vbYesNo) = vbYes Then UserWantsToAttach = True End Function Sub ExecuteInsertFileCommand() Application.ActiveInspector.CommandBars(\"Standard\").Controls(\"&File...\").Execute End Sub
Now I’m just dying to goof, so my computer can save me. The one problem I’ve found is that Outlook apparently pops up a confirmation box anytime a macro launches, to try to stave off Sasser, so that’s a bit annoying. I’ll see how long I can live with it.
BTW, for those who caught it, Pete Rose deserves to be in the Baseball Hall of Fame.