MacOS Mail and Tinderbox Dates

I have an AppleScript that will create a new note with a link to an email, which works fine.

I decided to “improve” it by adding the date the email was received to a User Attribute “$Received” of type “Date".

The script then promptly fails with this error:

I verified that $Received is of type Date:

ChatGPT suggested using “Evaluate” within the AppleScript, which appears below. The script runs without error, but $Received remains the default value “Never”.


use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

--set entryTitle to text returned of (display dialog "Entry Title?" default answer "")
set entryText to text returned of (display dialog "Entry Text?" default answer "")

tell application "Mail"
	--	if not it is running then activate
	
	if not (get selection) is {} then
		set theMsg to item 1 of (get selection)
	else
		return
	end if
	
	tell theMsg
		set {msgID} to {message id}
		set msgURL to "message://%3C" & msgID & "%3E"
		set senderText to sender of theMsg
		set subjectText to subject of theMsg
		set receivedDate to date received of theMsg
		set receivedDateText to short date string of receivedDate & " " & time string of receivedDate
	end tell
end tell

tell application id "Cere"
	activate
	set this_moment to (the current date)
	set nmMonth to (month of this_moment) as string
	set nmYear to (year of this_moment) as string
	set thePath to "Captain's Log/" & nmYear & "/" & nmMonth & " " & nmYear & "/" & date string of this_moment
	tell document "Captain's Log.tbx" -- suffix .tbx required on my machine
		-- this is how to specify a note down in the hierarchy:
		set theContainer to find note in it with path thePath
		set newNote to make new note at theContainer
		tell newNote
			--if entryTitle is not missing value then set value of attribute "Name" to entryTitle
			set value of attribute "Text" to entryText
			set value of attribute "Prototype" to "p_Email"
			set value of attribute "MailURL" to msgURL
			set value of attribute "Badge" to "mail-open"
			set value of attribute "Name" to subjectText
			set value of attribute "Sender" to senderText
			evaluate with "$Received=" & quoted form of receivedDateText & ";"
			
		end tell
	end tell
end tell


The relevant date information is accurately captured within the AppleScript itself:

Screenshot 2026-05-08 at 1.45.31 PM

(Screencap from Script Debugger)

ChatGPT has gone on to suggest a very elaborate fix that I don’t think will work. I figure it has to be something simple, so reaching out to the Forum for any insight or solutions. I need $Received to be of type Date so the notes are sorted properly.

Thanks in advance.

This aspect of software sucks. There are, I suspect two different forces of work hare. Code think != general human think, but neither is wrong lest we feel judgemental. These two ‘thinks’ live in two different worlds with different precepts.

Tinderbox 11 got an error: Can't make date "Wednesday, May 6, 2026
at 2:05:13 PM" into type text.

How can a string, stuff in quotes **not be a string? But, software is just as unintentionally inarticulate as the notional person on the upper deck of the Clapham omnibus.

At this point I’d log what the output ofthe previous phase is. It might look on screen like a string, but if not the extended type, what the is it. String => Fate conversion is far more complex than in the mind. Consider, is the string M>D or D>M order. To us it’s obvious, but code doesn’t infer.

So: look at the ‘bad’ input. It is what you expected. In a new script, try and use that value to set a date. Does it work? The failure of success might help you understand the string’ isn’t what you think.

This likely feels snarky at first read, but that is not my intent. Bottom line, what we assume != software’s assumption. Bottoming out the disconnect usually renders the fix. As the disconnection of understanding isn’t intention all it appears. Thus, it helps to hold onto an unintuitive degree of tolerance … The sailor you detailed off for the task didn’t disobey, they just truly didn’t understand nor did you ask if they’d actually understood. I find that paradigm easier to navigate than the faux-humanity of software.

†. Harry Potter fans look away now. UK is not actually still living in the 1950s, whatever the tiktok prolefeeds say.

‡. In this regard, controlling AI seems a sense of deja vu to my first career (at sea).

  • Command: wash Deck.
  • Reply: brush not found, instruction not understood.
  • Command: FFS…

Refreshingly, computers are just as dumb as humans, albeit in slightly different ways.

1 Like

ChatGPT is not nuts, and evaluate is one approach. I don’t think it’s necessary here.

I’d try set value of attribute "Received" to receivedDateText. I’m not certain that will work, but I think it should. (Depending on the version of your macOS, there might be a mandatory comma after the short date: 5/6/26, 8:08:32. Look at the dates Tinderbox generates to check.)

If that doesn’t work, try

set value of attribute "MyString" to receivedDateText
evaluate with "$Received=date($MyString);"

That works.

I had the impression, obviously false, that a data type in AppleScript, “Date” vice “text,” would be essential to Tinderbox recognizing it as a Date (data type) attribute.

Isn’t it all just “ticks” under the hood?

That is, my impression is that if I wanted AppleScript to return the Date Received as text, I would have to coerce it in AppleScript to text.

My impression now is that Tinderbox receives all attribute input (except booleans, perhaps) as text, and then coerces that text into whatever data type the attribute is defined as.

Is that the case?

Thanks, though. Easy fix. Works great!

Syntax error: No such command, “wash.”

Swab is the keyword.

For an assignment $Received= ...something..., the interpreter may or may not know the type of something, but it does know that $Received is a date. So $Received="today" works because Tinderbox can coerce that string to a date.

Most languages won’t let you do this. I thought that the action language would be much smaller than it turned out was needed, and that a permissive approach would be nice and would evade problems.