Assistance needed to add URL to Airmail message

With Keyboard Maestro and Hazel I am able to add an Airmail message to DEVONthink with the message date as the creation date. I would like to add the message URL to the record using a Smart Rule, but I’ve run into a roadblock.

The URL is on the clipboard and I can use set theURL to get the clipboard, but beyond that nothing I try seems to work. I imagine the balance of the Applescript is simpler than I’m making it.

Assistance will be greatly appreciated…

It might be helpful to post the script here, included in ``` (that is three backquotesn, once before and after the script).
Also

It’s not clear (to me). If setting the URL to the content of the clipboard works, what is it, that does not work?
Given that you

what stops you from writing a little AppleScript with the line that works?

This is my most recent try:

on performSmartRule(theRecords)
	tell application id "DNtp"
		set theSelection to the selection
		repeat with theRecord in theSelection
			set theURL to get the clipboard
			create record with {URL:theURL}
		end repeat
	end tell
end performSmartRule

It’s not clear (to me). If setting the URL to the content of the clipboard works, what is it, that does not work?

The following has worked for me:

set theURL to get the clipboard

The following shows the contents of the clipboard has been assigned to the variable, theURL:

display dialog theURL

what stops you from writing a little AppleScript with the line that works?

I don’t know how to take that question. I’m having trouble with the syntax…that’s the purpose of my post.

First off: using a script in a smart rule loops over all records selected by the smart rule. That seems to be a bit pointless here – unless you want to assign the same URL to all those records?
Second: You loop over all the records (repeat with ...) but you don’t do anything with them.
Third: You create a new record with no content and no type but with the content of the clipboard as its URL. This record might exist somewhere in DT, though it is probably not what you’re after.
Fourth: In order to set the URL of a record to the clipboard’s content, this should work:
set URL of theRecord to get the clipboard

It is not really clear what role Hazel plays in all that. Does it create a new record in DT and paste the mail’s URL to the clipboard? If so, you could simply add the URL to the record while you’re creating it. If not, how is the mail arriving in DT? Some more detail and context would really help here.

Your suggestion works! Thank you.

Here’s the entire script:

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			set URL of theRecord to get the clipboard
		end repeat
	end tell
end performSmartRule

Though there is just one record in the Inbox, the script will not function unless the line, repeat with theRecord in theRecords is present. This is not an issue because there is rarely more than one record to act on.

Regarding Hazel, it’s no longer necessary as I can export an Airmail email message to EML right to DEVONthink’s Inbox and the original date is preserved.