I've written a little C# VSTO add-in for Outlook 2003 that reads the body of emails as they are being sent, looking for certain words. It's working right now to do this:
if (currentItem.Body.Contains("text to search for"))
For the record, the solution I decided worked best for me was to simply check for a line starting with "FROM:", Mikael suggested. I stop searching for my text as soon as that is found. That's been working just fine for me for a while now.
Thanks for the responses and ideas, everyone.
Here's my code for reference:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim theLine As String Dim aBody() Dim bFound As Boolean Dim ctr As Long aBody = Array(Split(Item.Body, vbNewLine)) bFound = False For ctr = 0 To UBound(aBody(1)) theLine = aBody(1)(ctr) If InStr(theLine, "From:") > 0 Then Exit For End If If InStr(UCase(theLine), "ATTACH") > 0 Then bFound = True End If Next If bFound Then If Item.Attachments.Count < 1 Then Dim ans As Integer ans = MsgBox("Do you really want to send this without any attachments?", vbYesNo) If ans = 7 Then Cancel = True Exit Sub End If End If End If End Sub