Well, it was an interesting exercise converting my Applescript see below. The script will process a number of emails selected in Apple Mail and copy the details to the clipboard. These can then be pasted into Tinderbox. See the comments in the script. You need to define a prototype and ensure that the date field/attribute is given a type of string.
Use at your own risk.
best wishes
Simon K.
Blockquote
(*
A script that parses a number of emails that have been selected in Apple’s Mail application.
Certain key data are extracted and saved to variables.
The body of the email is cleaned of tabs and linefeeds with
linefeed replaced with UTF-8 line separator character (8232)
The lines of data are copied to the clipboard ready to be
pasted into Tinderbox.
Note create a prototype note named protoEmail and give it
an attribute named DateSent of type string. If you don’t then
Tinderbox will give it type date and display an incorrect date.
written by Simon Knight August 2018, Use at own risk!
*)
– First Copy the data in the email to variables
tell application “Mail”
– get all the messages in the list with same subject
set tMessageList to selection
set tEmail to “”
set tdata to “”
set tline to “”
–set x to 1 – Originally I grabbed all the emails in the selection in a repeat loop
repeat with x from 1 to (count tMessageList)
–From:
set tSender to the sender of (item x) of tMessageList
–Subject:
set tSubject to the subject of (item x) of tMessageList
–Date:
set tDateSent to the date sent of (item x) of tMessageList
–To:
set tRecipients to the recipients of (item x) of tMessageList
set tAddresseeList to ""
repeat with n from 1 to (count tRecipients)
set tAddressee to (item n) of tRecipients
set tAddresseeList to tAddresseeList & address of tAddressee & " / "
end repeat --list of recipients
-- Message Body
set tContent to the content of (item x) of tMessageList
set tFind to linefeed
set tReplace to character id 8232
set tBodyText to CleanText(tFind, tReplace, tContent) of me
set tFind to tab
set tReplace to "---"
set tBodyText to CleanText(tFind, tReplace, tBodyText) of me
set tFind to character id 13
set tReplace to character id 8232
set tBodyText to CleanText(tFind, tReplace, tBodyText) of me
-- build a line for output
set tline to tSubject & tab & tBodyText & tab & tSender & tab & tDateSent & tab & tAddresseeList & tab & "protoEmail"
set tdata to tdata & linefeed & tline
end repeat -- list of selected messages
end tell – Apple Mail
– build header row
set tHeaders to “Name” & tab & “Text” & tab & “From” & tab & “DateSent” & tab & “Addressees” & tab & “Prototype”
set tExport to tHeaders & tdata
–set the clipboard to tExport
set the clipboard to tExport as «class utf8»
– uncomment the following lines if you wish a text file saved to the desktop, delete the “(" and ")”
(*
set outputFile to ((path to desktop as text) & “SelectedEmails.txt”)
try
set fileReference to open for access file outputFile with write permission
–write tBodyText to fileReference without altering line endings
write tExport to fileReference as «class utf8»
close access fileReference
on error
try
close access file outputFile
end try
end try
*)
beep
on CleanText(pFind, pReplace, pText)
– save the existing delimiters
set prevTIDs to text item delimiters
-- find the newline hex 0A characters
set text item delimiters to pFind
set tText to text items of pText
-- add the replacement character / string
set text item delimiters to pReplace
set tText to tText as text
-- resset the delimiters back to how they were
set text item delimiters to prevTIDs
return tText
end CleanText