如何在 Cocoa 应用程序中获取删除的邮件消息数据?

发布于 2024-09-30 23:36:22 字数 957 浏览 7 评论 0原文

我正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

国粹 2024-10-07 23:36:22

我用苹果的 PasteboardPeeper 示例代码进行了尝试(来自 http:// /developer.apple.com/library/mac/#samplecode/PasteboardPeeker/Introduction/Intro.html),并将消息拖到主目录中确实显示该消息的路径可用:

PasteboardRef: 1395632  ItemCount: 1
   Index: 1  item ID: 789514
      "dyn.ah62d4rv4gu8y4zvanr41xxxxx30n25wqz4ca5pfsr30c35feb4he2pssrxgn6vasbu1g7dfqm1"
      "MV Super-secret message transfer pasteboard type"
      '' ______ 82  /Users/guest/Library/Mail/[email protected]@imap.gmail.com/INBOX.imapmb

      "dyn.ah62d4rv4gu8zg7puqz3c465fqr3gn7bakf41k55rqf4g86vasbu1g7dfqm10c6xeeb4hw6df"
      "Super-secret Automator pasteboard type"
      '' ______ 454  <?xml version= 1.0  encoding= UTF-8 ?> < DOCTYPE plist PUBLIC  -//Apple//DTD PLI

      "dyn.ah62d4rv4gu8yc6durvwwa3xmrvw1gkdusm1044pxqyuha2pxsvw0e55bsmwca7d3sbwu"
      "Apple files promise pasteboard type"
      '' ______ 212  <?xml version= 1.0  encoding= UTF-8 ?> < DOCTYPE plist PUBLIC  -//Apple//DTD PLI

      "public.url"
      ""
      'url ' ______ 74  message: [email protected] 3E

      "public.url-name"
      ""
      'urln' ______ 56  A friend thought you would be interested in this station

      "com.apple.pasteboard.promised-file-content-type"
      ""
      '' ______ 23  dyn.ah6xxxqmxhk2x43prru

      "com.apple.pasteboard.promised-file-url"
      ""
      '' ______ 0  

      "dyn.ah62d4rv4gu8y6y4usm10xxxxqzb085xyqz1hk64uqm10c6xenv61a3k"
      "NSPromiseContentsPboardType"
      '' ______ 0  

      "dyn.ah62d4rv4gk81a4dgsq"
      ""
      'phfs' PT____ 14  ????????  Pssf

我不知道“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:

PasteboardRef: 1395632  ItemCount: 1
   Index: 1  item ID: 789514
      "dyn.ah62d4rv4gu8y4zvanr41xxxxx30n25wqz4ca5pfsr30c35feb4he2pssrxgn6vasbu1g7dfqm1"
      "MV Super-secret message transfer pasteboard type"
      '' ______ 82  /Users/guest/Library/Mail/[email protected]@imap.gmail.com/INBOX.imapmb

      "dyn.ah62d4rv4gu8zg7puqz3c465fqr3gn7bakf41k55rqf4g86vasbu1g7dfqm10c6xeeb4hw6df"
      "Super-secret Automator pasteboard type"
      '' ______ 454  <?xml version= 1.0  encoding= UTF-8 ?> < DOCTYPE plist PUBLIC  -//Apple//DTD PLI

      "dyn.ah62d4rv4gu8yc6durvwwa3xmrvw1gkdusm1044pxqyuha2pxsvw0e55bsmwca7d3sbwu"
      "Apple files promise pasteboard type"
      '' ______ 212  <?xml version= 1.0  encoding= UTF-8 ?> < DOCTYPE plist PUBLIC  -//Apple//DTD PLI

      "public.url"
      ""
      'url ' ______ 74  message: [email protected] 3E

      "public.url-name"
      ""
      'urln' ______ 56  A friend thought you would be interested in this station

      "com.apple.pasteboard.promised-file-content-type"
      ""
      '' ______ 23  dyn.ah6xxxqmxhk2x43prru

      "com.apple.pasteboard.promised-file-url"
      ""
      '' ______ 0  

      "dyn.ah62d4rv4gu8y6y4usm10xxxxqzb085xyqz1hk64uqm10c6xenv61a3k"
      "NSPromiseContentsPboardType"
      '' ______ 0  

      "dyn.ah62d4rv4gk81a4dgsq"
      ""
      'phfs' PT____ 14  ????????  Pssf

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文