Correct url of eml records

  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