I have done some research on Apple mail and find this:MUIWebDocumentPasteboardType
I have extract it to a file and it looks like this, the pasteboardType is binary plist.
The last line is a string I’m intresting in. (HTML Source) of the email.
So I made this code and it give the string but I wonder if there is a better way, to do this ??
use framework "Foundation"
use framework "AppKit"
use scripting additions
set thePath to POSIX path of (choose file)
set theURL to current application's |NSURL|'s fileURLWithPath:thePath
set theData to current application's NSData's dataWithContentsOfURL:theURL
set plist to current application's NSPropertyListSerialization's propertyListWithData:theData options:(current application's NSPropertyListImmutable) format:(missing value) |error|:(missing value)
set theObject to plist's objectForKey:"$objects"
set theString to (theObject's objectAtIndex:2) as text
set theObject to plist's objectForKey:"$objects"
set theString to (theObject's objectAtIndex:2) as text
Rather than NSPropertyListSerialization you should use NSKeyedUnarchiver — the presence of NSKeyedArchiver tells you how it was made. Use +unarchiveObjectWithData: or + unarchiveObjectWithFile:.
use framework "Foundation"
use framework "AppKit"
use scripting additions
set thePath to POSIX path of (choose file)
set theURL to current application's |NSURL|'s fileURLWithPath:thePath
set theData to current application's NSData's dataWithContentsOfURL:theURL
set theUnarchiver to current application's NSKeyedUnarchiver's unarchiveObjectWithData:theData
So if I understand you correctly, I couldn’t use NSKeyedUnarchiver or would it involve a more
complicated process.
I need to read more about this because my knowledge is very limited, I have never done any
examples with NSKeyedArchive before. The first time I heard about it was when I read on wikipedia
about webarchive.
The approach we choose for the moment maybe are not what we want, but its bold to do something
more complicated because in return we could learn something new from it.
That’s correct. You’d have to do something like create a version of the class yourself, reverse-engineering parts of it from the property list. It may or may not even be possible.