Thanks everyone for your help. This is definitely odd.
So this does work for me:
tell application “Mail”
set the clipboard to (content of first message of inbox whose subject contains “music”) as string
end tell
but if I change the string to be found to “reports” I get an error, even though I’m looking at an email with that in the subject.
If I try
tell application “Mail” to set mymsg to (messages of inbox whose subject contains “J-List”)
I can get the list of messages that start with (not “contains” it seems) the phrase J-List, and access them, open them, get contents from them. But if I try to specifically do this for mails whose subject contains “J-List Reports” then it breaks again, even though I am looking at the mail with that in the subject.
Sadly it seems to just be broken.
The only way I can think of accessing the mails I need is to loop it and check each message. The following works okay
tell application “Mail”
set inboxCount to count messages of inbox
repeat with i from 1 to inboxCount
set the clipboard to (subject of message i of inbox) – subject is always text
set theSub to (subject of message i of inbox) – subject is always text
set myoffset to offset of “J-List” in theSub
if myoffset is not 0 then
say “found report”
set theContent to (content of first message of inbox whose subject contains theSub) as string – rich text
open message i of inbox
end if
end repeat
end tell
but if I change my search string from “J-List” to “J-List reports” then I get nothing.
So it seems there may be two errors
a) a huge weirdness in indexing that causes some Applescript logic to be unrealiable (can anyone else confirm?)
and
b) since the mails I’m trying to grab content from are plain text, not HTML or anything, there seems to be a “blindness” via Applescript. No script I make which carefully checks each message for my criteria will “see” the mails I want, but seem to be okay with seeing normal HTML mails.