Apple script access to messages

Hello!

I am trying to write a script that searches the EagleFiler library for emails based on the source URL. This works great in the GUI, but I can’t automatically open emails in mail.app if the emails are in an mbox. This works if the email is a standalone eml file.

The exact script I have is as follows:

	messageID = "<ad5e038a-3440-071f-1a0d-7eb19da76a55@example.tx>"
	try
		tell application "EagleFiler"
			if not (exists browser window 1) then
				make new browser window
			end if
			set search query of browser window 1 to messageID
			activate
			delay 0.2
			set visibleResults to displayed records of browser window 1
			if (count of visibleResults) > 0 then
				set theRecord to item 1 of visibleResults
				set selected records of browser window 1 to {theRecord}
				set emlFile to (file of theRecord) as alias
                tell application "Mail"
                     open emlFile
                     activate
                end tell
		set foundInEF to true
              	display dialog "Found email: " & (POSIX path of emlFile)
			end if
		end tell
	end try

It seems that displayed records does not expose the emails if they are in an mbox but does if they are a eml file.

My ask: any suggestions or workarounds?

Yes, currently e-mails within mbox files are not accessible via AppleScript. I’m in the process of rearchitecting EagleFiler to make that possible.

Wonderful, looking forward to it!