when dropping emails to DT manually, we get in the .elm info, a mailto:{…} URL that makes no sense to me, I want to get it to show the message callback in the form message:\{messageID}.
but something is wrong in my code and I don’t know why.
script editor returns the correct result, but DT does not.
script editor with hardcoded string (working - please forgive the xxxx and yyyy I had to put for confidentiality):
set myURL to “mailto:xxxx?subject=Re:%xxxxx&in-reply-to=%3Cyyyyyy@yyyyy%3E” set mystring totext item 2 of splittext(myURL, “%3C”) asstring set mystring to “message:%3C” & mystring display dialog mystring on splittext(theText, theDelimiter) set AppleScript’s text item delimiters to theDelimiter set theTextItems toeverytext itemof theText set AppleScript’s text item delimiters to “” return theTextItems end splittext
DT embedded script (not returning anything):
on performSmartRule(theRecords) tellapplicationid “DNtp” repeatwith theRecord in theRecords set myURL to URL of theRecord asstring set mystring totext item 2 of splittext(myURL, “%3C”) asstring set mystring to “message:%3C” & mystring display dialog mystring endrepeat endtell end performSmartRule on splittext(theText, theDelimiter) set AppleScript’s text item delimiters to theDelimiter set theTextItems toeverytext itemof theText set AppleScript’s text item delimiters to “” return theTextItems end splittext
this second script does not return mystring
…anyone can help?
it works! thanks!
just to wrap that up for anyone interested, the code below modifies the url of .eml files (in a quick & dirty way) so that they open in the default OS mail app:
on performSmartRule(theRecords)
tell application id "DNtp"
repeat with theRecord in theRecords
set myURL to URL of theRecord as string
set mystring to text item 2 of my splittext(myURL, "%3C") as string
set mystring to "message:%3C" & mystring
set URL of theRecord to mystring
end repeat
end tell
end performSmartRule
on splittext(theText, theDelimiter)
set AppleScript's text item delimiters to theDelimiter
set theTextItems to every text item of theText
set AppleScript's text item delimiters to ""
return theTextItems
end splittext
PS: The email will still open in the system default email application without using this script. The difference is, in the normal state of things it opens a reply to email. With your modification, it opens the original email.
That’s indeed what I wanted to accomplish. For some reason the “reply to” does not show the original message. And I find that displaying the original message helps in checking the thread for replies received after clipping it to DT.
Thanks again!
The message id returned by Mail is incomplete. You would see this in the Replies section of the Script Editor.
You can’t set the URL of the file at import time (though @cgrunenberg would have to assess if that’s correct behavior or not).
tell theMessage
set {theDateReceived, theDateSent, theSender, theSubject, theSource, theReadFlag, theID} to {the date received, the date sent, the sender, subject, the source, the read status, message id}
end tell
set msgID to "message://%3c" & theID & "%3e"
if theSubject is equal to "" then set theSubject to pNoSubjectString
tell application id "DNtp"
set newRecord to (create record with {name:theSubject & ".eml", type:unknown, creation date:theDateSent, modification date:theDateReceived, source:(theSource as string), unread:(not theReadFlag)} in theGroup) -- Removed URL property
set URL of newRecord to msgID -- Set the URL here
end tell