I’m working on a Cocoa application into which I’d like to allow Mail messages to be dropped.
If I include public.plain-text in my Info.plist Document Types, I can drop a Mail message on the icon in the Dock and get a file path like this from the application:openFiles: delegate method:
"/Users/smokris/Library/Caches/TemporaryItems/Re_ multiplexer question 3.eml"
…and I can read the raw message data from this file. So far so good.
However, I also want the user to be able to drop Mail messages on the application window. So I do this:
[window registerForDraggedTypes:[NSArray arrayWithObjects:(NSString *)kPasteboardTypeFileURLPromise,nil]];
…and in performDragOperation:, I get a URL like this from the pasteboard:
message:%3CAANLkTikeTeWYU39JpTovxF2PC0Mm=xkrU7fHNh6gGh6V@mail.gmail.com%3E
If I try doing an NSURLRequest on this URL, it gives me the error “unsupported URL”.
How can I get the raw message data from this message: URL?
I tried it out with Apple’s PasteboardPeeper sample code (from http://developer.apple.com/library/mac/#samplecode/PasteboardPeeker/Introduction/Intro.html), and dragging a message into the main did show that the path of the message is available:
I don’t know what “MV Super-secret message transfer pasteboard type” is, but you might not want to rely on it as a key name; rather, maybe you could just walk through all the keys and see if any of them look like a file path.
P.S. This might also be of interest: http://www.wuffwuffware.com/developer.html