Correct url of eml records

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 to text item 2 of splittext(myURL, “%3C”) as string
set mystring to “message:%3C” & mystring
display dialog mystring
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

DT embedded script (not returning anything):

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 splittext(myURL, “%3C”) as string
set mystring to “message:%3C” & mystring
display dialog 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

this second script does not return mystring
…anyone can help?

The URL of an imported email is a reply email address for quickly replying to it, even via the Data > Send Reply.

You mean like this…

You’re missing a my before calling the handler.

set mystring to text item 2 of my splittext(myURL, “%3C”) as string

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

You’re welcome.

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!

How can I modify “Add message(s) & attachments to DEVONthink” script to get URL of a message? Can you help me please…

Which URL actually? Right now the email address of the sender is used by the scripts.

Link of a message - for example “ message:%3C100423.549497696.202005071621362692877.0006168734@enews.com” instead the email address of the sender

Instead of the sender you would have to use message id:

Thanks

it doesn’t work! I get “20200518061432.1BBCC2A9EC3@005.de-mx.crsend.com” instead “message:%3C20200518061432.1BBCC2A9EC3@005.de-mx.crsend.com%3E”

  1. The message id returned by Mail is incomplete. You would see this in the Replies section of the Script Editor.
  2. 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

Thank you very much! It works))))

No problem