Below is the code I have so far. The variable theMessage is getting set to a message correctly but I can’t pull the ID.
tell application "Mail"
make new message viewer with properties {selected mailboxes:{inbox}}
end tell
tell application "Mail"
activate
tell account "Gmail"
tell mailbox "INBOX"
set theMessage to {first message whose subject is "hey you"}
set theid to the theMessage
display dialog theMessage as text
tell application "Mail" to open (messages of account "Gmail" of mailbox "INBOX" whose id is theMessage)
end tell
end tell
display dialog theMessage as text
end tell