OK, the problem seems to have to do with “embedded” file attachments. I’ve been able to access and save out file attachments using this code:
Code:
tell note of theItem
set NumberOfFileAttached to number of file attachment
set i to 1
set ListOfPaths to {}
repeat while i ≤ NumberOfFileAttached
if embedded of file attachment i then
set tempFilePath to my pathForTemporaryFile("OmniFocus")
tell file attachment i
save in tempFilePath
end tell
set end of ListOfPaths to tempFilePath
else
set end of ListOfPaths to file name of file attachment i as string
end if
set i to i + 1
end repeat
end tell
This raises a new problem: embedded file attachments are saved as files with no type. I’ll start a new thread for this.