I think this is the problematic line:
make new file attachment with properties {file name:MyFile, embedded:true}
In the new sandboxed world, you need to let AppleScript know that you want to pass that variable as a file rather than a string, so it can grant access to the app you’re scripting:
make new file attachment with properties {file name:POSIX file MyFile, embedded:true}
Hope this helps!