Export von MacMail in DevonThink - Skripterweiterung/-anpassung

Hallo,
ich habe schon ein erweitertes Skript für MacMail, damit die Mails nicht im Eingang, sondern in einer gewünschten Datenbank in einem gewünschten Ordner landen.

Jetzt würde ich gerne das Skript dahingehend angepasst bekommen, damit es auch “markierte” E-Mails entsprechend behandelt.

Aktuell ist es so, dass er diese Mails wie gewünscht in DevonThink importiert. Dabei werden auch die Merkmale wie gelesen/ungelesen beachtet und entsprechend übertragen.
Jedoch ist es so, dass in MacMail markierte E-Mails (egal welcher Farbe) in DevonThink nicht erkennbar sind. Die Markierungen fehlen.

Was ich möchte:
Ich möchte das die E-mails die in MacMail eine Markierung haben, entsprechend übertragen werden.
Alternative 1:
Entweder erhalten die E-Mails durch den Import das Kennzeichen “markiert”. Somit wäre die farbliche Markierung in MacMail egal, da es in DevonThink nur eines gibt. Markiert ja oder nein.
Alternative 2:
Es findet ein Matching zwischen Markierung Mac Mail und Etikett DevonThink statt.
7 Farb-Markierung gibt es in MacMail, 7 Farb-Etiketten gibt es in DevonThink.

(Alternative 2 wäre schon die “luxus”-Variante, mir würde aber schon Variante 1 reichen)

Mein aktuelles Apple-Skript sieht so aus:

-- Mail Rule - Add messages to DEVONthink
-- Created by Christian Grunenberg on Mon Apr 19 2004.
-- Copyright (c) 2004-2020. All rights reserved.

-- this string is used when the message subject is empty
property pNoSubjectString : "(no subject)"

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			repeat with theMessage in theMessages
				try
					tell theMessage
						set {theDateReceived, theDateSent, theSender, theSubject, theSource, theReadFlag} to {the date received, the date sent, the sender, subject, the source, the read status}
					end tell
					if theSubject is equal to "" then set theSubject to pNoSubjectString
					tell application id "DNtp"
						--set theRecord to create record with {name:theSubject & ".eml", type:unknown, creation date:theDateSent, modification date:theDateReceived, URL:theSender, source:(theSource as string), unread:(not theReadFlag)} in incoming group
						set theDest to get record at "/--= Neu-Import =--" in database "E-Mails"
						set theRecord to create record with {name:theSubject & ".eml", type:unknown, creation date:theDateSent, modification date:theDateReceived, URL:theSender, source:(theSource as string), unread:(not theReadFlag)} in theDest
	⁃					perform smart rule trigger import event record theRecord
					end tell
				end try
			end repeat
		end tell
	end perform mail action with messages
end using terms from

Diese kleine Änderung entspricht Variante 1, geändert haben sich dabei eigentlich nur 2 Zeilen:

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		tell application "Mail"
			repeat with theMessage in theMessages
				try
					tell theMessage
						set {theDateReceived, theDateSent, theSender, theSubject, theSource, theReadFlag, theFlag} to {the date received, the date sent, the sender, subject, the source, the read status, the flagged status}
					end tell
					if theSubject is equal to "" then set theSubject to pNoSubjectString
					tell application id "DNtp"
						set theDest to get record at "/--= Neu-Import =--" in database "E-Mails"
						set theRecord to create record with {name:theSubject & ".eml", type:unknown, creation date:theDateSent, modification date:theDateReceived, URL:theSender, source:(theSource as string), unread:(not theReadFlag), state:theFlag} in theDest
						perform smart rule trigger import event record theRecord
					end tell
				end try
			end repeat
		end tell
	end perform mail action with messages
end using terms from

Vielen Dank.
Ich werde es ausprobieren.