如何在 Cocoa 应用程序中获取删除的邮件消息数据?
我正在开发一个 Cocoa 应用程序,我希望允许将邮件消息放入其中。
如果我在 Info.plist 文档类型中包含 public.plain-text
,我可以将邮件消息放在 Dock 中的图标上,并从 application:openFiles 获取如下文件路径:
委托方法:
"/Users/smokris/Library/Caches/TemporaryItems/Re_ multiplexer question 3.eml"
...我可以从此文件中读取原始消息数据。到目前为止,一切都很好。
但是,我还希望用户能够将邮件消息放到应用程序窗口上。所以我这样做:
[window registerForDraggedTypes:[NSArray arrayWithObjects:(NSString *)kPasteboardTypeFileURLPromise,nil]];
...在 performDragOperation:
中,我从粘贴板中得到一个像这样的 URL:
message:%[email protected]%3E
如果我尝试在这个 URL 上执行 NSURLRequest
,它会给我错误“不支持的 URL”。
如何从此 message:
URL 获取原始消息数据?
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:%[email protected]%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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我用苹果的 PasteboardPeeper 示例代码进行了尝试(来自 http:// /developer.apple.com/library/mac/#samplecode/PasteboardPeeker/Introduction/Intro.html),并将消息拖到主目录中确实显示该消息的路径可用:
我不知道“MV超密消息传输粘贴板类型”是什么,但您可能不想依赖它作为密钥名称;相反,也许您可以浏览所有键,看看它们中是否有任何一个看起来像文件路径。
PS 这可能也令人感兴趣:http://www.wuffwuffware.com/developer.html
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