Long story short, I’m importing emails into DT, converting to RTF to add highlighting, and then I later need to merge each conversation’s emails to end up with one long RTF, complete with highlighting. I want to do this with a script rather than Merge as I want to automatically set the document title and eventually reset the date to the first email date.
The script below works great, with one problem - it loses the formatting and highlighting. The resulting document is an RTF document, but with plain text in it, and I can’t figure out what I’m doing wrong. Any clues please?
Here’s the script:
tell application id "com.devon-technologies.thinkpro2"
activate
try
set theGroup to create location "Emails Merge Test"
set theSelection to the selection
set theName to ""
set theContent to "" as styled text
set blankLines to (return & return) as styled text
repeat with theItem in theSelection
if theName is "" then
set theName to "PR Email - " & name of theItem
end if
set theContent to theContent & (rich text of theItem) & blankLines
end repeat
set theRecord to create record with {name:theName, type:rtf, rich text:""}
set the rich text of theRecord to theContent
move record theRecord to theGroup
on error error_message number error_number
if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
end try
end tell