Mail AppleScript broken on Catalina

I’ve been using a version of flag 2 omnifocus for many years now. I just can’t get out of the habit of using flags to send things to OF.

However, in Catalina my script is broken…

        tell application "Mail"
			repeat with _acct in accounts
				set _acct_status to enabled of _acct

Gives an error of:

error "Mail got an error: AppleEvent handler failed." number -10000

Anyone have any workarounds for this? Still happening on 10.15.3 :confused:

What if you try set _all_accts_status to enabled of every account ?

Obviously inside an appropriate tell block targeting Mail.

Also, what’s the rest of the script that we can’t see like ? Willing to post it ?

The whole script is (with some folders and account names changed):

on run
	set _mywork_interesting_mailboxes to {"Inbox", "0TOOLS",  "00Inbox - CC"}
	set _omnifocus_followup to "1OMNIFOCUS"
	with timeout of 90000 seconds
		-- first find our Exchange account so we only store follow up items there
		tell application "Mail"
			repeat with _acct in accounts
				set _acct_status to enabled of _acct
				if _acct_status is true then
					set _acct_type to account type of _acct
					if _acct_type is unknown then
						set _acct_server to server name of _acct
						set _acct_name to name of _acct
						if _acct_server contains ".mywork.domain" then
							set mywork_exchange to _acct_name
						end if
					end if
				end if
			end repeat
		end tell
		
		tell application "Mail"
			
			repeat with _acct in accounts
				set _acct_status to enabled of _acct
				if _acct_status is true then
					
					--Look For Flagged Messages in the INBOX
					set _acct_name to name of _acct
					set _acct_type to account type of _acct
					--if _acct_type is unknown then
					if _acct_name is mywork_exchange then
						#set _inbox to _acct's mailbox "Inbox"
						set _mailbox_list to _mywork_interesting_mailboxes
					else
						#set _inbox to _acct's mailbox "INBOX"
						if _acct_type is unknown then
							set _mailbox_list to {"Inbox"}
						else
							set _mailbox_list to {"INBOX"}
						end if
					end if
					
					
					repeat with _mbx in _mailbox_list
						set _inbox to _acct's mailbox _mbx
						
						set _msgs_to_capture to (every message of _inbox whose flagged status is true)
						repeat with eachMessage in _msgs_to_capture
							
							
							set theStart to missing value
							set theDue to missing value
							set theOmniTask to missing value
							
							set theTitle to the subject of eachMessage
							set theNotes to the content of eachMessage
							
							set theCombinedBody to "message://%3c" & message id of eachMessage & "%3e" & return & return & theNotes
							
							tell application "OmniFocus"
								tell default document
									set newTaskProps to {name:theTitle}
									if theStart is not missing value then set newTaskProps to newTaskProps & {defer date:theStart}
									if theDue is not missing value then set newTaskProps to newTaskProps & {due date:theDue}
									if theCombinedBody is not missing value then set newTaskProps to newTaskProps & {note:theCombinedBody}
									
									set newTask to make new inbox task with properties newTaskProps
								end tell
							end tell
							
							set flagged status of eachMessage to false
							move eachMessage to mailbox _omnifocus_followup of account mywork_exchange
						end repeat
					end repeat
				end if
			end repeat
		end tell
	end timeout
end run
on run
	tell application "Mail"
		set _all_accts_status to enabled of every account
	end tell
end run

also gives

error "Mail got an error: AppleEvent handler failed." number -10000

Did you find a solution and if so are you willing to share?

It just started working again at some update. I don’t know which