title: Apple Mail attachments to Apple Notes via Applescript
body: <p>I'm working on a script that copies Apple Mail mails into Apple Notes. So far so good, but I am having troubles getting the attachments into the newly created note. This is on macOS Catalina 10.15.7.</p>
  <p>I spent half a day yesterday looking for solutions, but they all do not work.
  When I execute a <code>make new attachment</code> statement, I get the following kind of error for each attachment found in the email: <code>Notes got an error: Can’t make show id &quot;x-coredata://32E6D9EF-97F3-424F-B151-DD166A00E0AB/ICNote/p9725&quot; into type specifier.</code> This UID is the same for each attachment.</p>
  <p>I tried various path variations (as POSIX file, as text, or just as is) but all give the same error.</p>
  <p>This simple code example already gives the error on line 2:</p>
  <pre><code>set theNote to make new note at folder NotesFolder with properties {body:theBody}
  make new attachment at theNote with data theFileName
  </code></pre>
  <p>where theFileName is the complete path to the email-attachment, temporarily saved in a folder on the desktop so Applescript and Notes can have access to it.
  Since the UID in the error message is the same for every found attachment, it can also be that <code>theNote</code> is not ok.</p>
  <p>Any ideas what is wrong with this? Or is it Notes having problems (I've read that Notes in Catalina seems to have Applescripting bugs)</p>
  <p>I'm at a loss, currently, so any help is much appreciated.</p>