How to find specific words in email?

I have the following script for replying to emails:

set myReply to "Override"

set theSender to "Me <me@gmail.com>"

tell application "Mail"
    set theSelection to selection
    if theSelection is {} then return
    activate
    set myList to {}
    repeat with thisMessage in theSelection
        if (extract address from sender of thisMessage) is "watson@gmail.com" then
            set theOutgoingMessage to reply thisMessage with properties {visible:true, sender:theSender}
            delay 1
            tell application "System Events"
                keystroke myReply
                delay 1
            end tell
            send theOutgoingMessage
            delay 1
            set myList to myList
            delay 1
        end if
    end repeat
end tell

How can I find a specific word in the whole body of the message when I don’t know in which paragraph it is exactly located? I want to find “incompatible classes”.

I was about to ask why you use System Events to compose the content of a message. Then I saw that content is of type rich text. It’s really impressive how Apple manages to botch a very simple concept like “send clear text via the network” :frowning:

Regarding your question: You’d probably use the content of the message you want to reply to and search for the string in it. Something like content as string contains "whatever". Not sure if the as string is needed. Since I don’t do AppleScript, I don’t know much about it