When a message gets replied or forwared the previous thread gets appended on your new mail by placing i.e. ----Original Message---- in front of it.
Outlook does the same with tekst messages but with HTML mails it shows a line followed with From:..
Since outlook shows a line in between these messages i believe it's possible to subtract these messages using VBA. But How?
Goal: When the user sends a mail (Application_ItemSend) I want to scan the message for certain words. But I don't care if it occurs in a previous message, i only want to scan the newly typed message.
The example below will work when answering an email in outlook when it's in text (and outlook is in english!). But it will NOT work when sending a HTML email.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim EndOfMsg As Integer
Dim myMsg as String
EndOfMsg = InStr(Item.Body, "-----Original Message-----")
If EndOfMsg = 0 Then
myMsg = Item.Body
Else
myMsg = Left(Item.Body, EndOfMsg)
End If
MsgBox myMsg
End Sub
So i need some 'token' to split on, correct.. But what is this token? All there is between myMsg and the older msg's is a double vbCrLf
. The same as when i enter a new line in my message.. no nothing at all unique!