- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 cocoa 应用程序,我想接受来自 mail.app 的电子邮件,并将其拖到应用程序的主窗口中。我的应用程序中有DidFinishLaunching:
[_window registerForDraggedTypes:
[NSArray arrayWithObjects:
NSFilenamesPboardType,
(NSString *)kPasteboardTypeFileURLPromise, nil]]; //kUTTypeData
[_window setDelegate:(id) self];
这工作正常,我可以在我的performDragOperation中接收文档:使用
NSArray * files = [sender namesOfPromisedFilesDroppedAtDestination:url];
但是,这只能让我一封一封地拖动电子邮件。如果我标记几封电子邮件,一切看起来都很好,直到我删除,然后什么也没有发生。甚至没有调用performDragOperation。
我尝试将 kUTTypeData 添加到 registerForDraggedTypes...,然后调用了 PerformDragOperation...,但随后我无法使用 namesOfPromisedFilesDroppedAtDestination:url,因为它返回一个 nil 指针。
当我将 kUTTypeData 包含在寄存器中时...我将其包含在 PerformDragOperation 中以查看拖动的类型:
pboard = [sender draggingPasteboard];
NSLog(@"perform drag entered, %@", [pboard types]);
结果如下:
2013-07-25 15:09:50.771 BO2ICAL[1672:303] perform drag entered, (
"dyn.ah62d4rv4gu8y4zvanr41a3pwfz30n25wqz4ca5pfsr30c35feb4he2pssrxgn6vasbu1g7dfqm10c6xeeb4hw6df",
"MV Super-secret message transfer pasteboard type",
"dyn.ah62d4rv4gu8zg7puqz3c465fqr3gn7bakf41k55rqf4g86vasbu1g7dfqm10c6xeeb4hw6df",
"Super-secret Automator pasteboard type"
)
单个电子邮件的列表是:
2013-07-25 15:14:30.096 BO2ICAL[1672:303] perform drag entered, ( "dyn.ah62d4rv4gu8y4zvanr41a3pwfz30n25wqz4ca5pfsr30c35feb4he2pssrxgn6vasbu1g7dfqm10c6xeeb4hw6df", "MV Super-secret message transfer pasteboard type", "dyn.ah62d4rv4gu8zg7puqz3c465fqr3gn7bakf41k55rqf4g86vasbu1g7dfqm10c6xeeb4hw6df", "Super-secret Automator pasteboard type", "dyn.ah62d4rv4gu8yc6durvwwa3xmrvw1gkdusm1044pxqyuha2pxsvw0e55bsmwca7d3sbwu", "Apple files promise pasteboard type", "public.url", "CorePasteboardFlavorType 0x75726C20", "dyn.ah62d4rv4gu8yc6durvwwaznwmuuha2pxsvw0e55bsmwca7d3sbwu", "Apple URL pasteboard type", "public.url-name", "CorePasteboardFlavorType 0x75726C6E", "com.apple.pasteboard.promised-file-content-type", "com.apple.pasteboard.promised-file-url", "dyn.ah62d4rv4gu8y6y4usm1044pxqzb085xyqz1hk64uqm10c6xenv61a3k", NSPromiseContentsPboardType )
有人对如何正确执行此操作以接受多封电子邮件有任何建议吗?
最佳答案
我已经找到了解决这个问题的方法。我发现“kUTTypeData”模式中提供的数据为我提供了足够的数据来直接从 mail.app 邮箱获取文件。
在mbox文件夹中,有一个带有一长串数字和破折号的文件夹,在邮箱层次结构中的任何地方都没有这个名称的痕迹,但由于它只包含这个文件夹和一个info.plist文件,所以我使用此函数可以获取该名称:更新:实现了正则表达式检查,因为该文件夹有时包含可能具有更长名称的子邮箱...
-(NSString*)FindCodedFolderInMailbox:(NSString*)mailboxpath {
NSString *uuid_regexp = @"[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}";
NSPredicate *uuid_test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", uuid_regexp];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *fileList = [fileManager contentsOfDirectoryAtPath:mailboxpath error:nil];
for (NSString * file in fileList) {
if ([uuid_test evaluateWithObject: file]){
return file;
}
}
return nil;
}
然后我发现没有“NSPromiseContentsPboardType”,而是“ super secret 自动化粘贴板类型”的部分,我写了以下部分(我打算删除一些 NSLog 条目,但这里是:
} else if ( [[pboard types] containsObject:@"Super-secret Automator pasteboard type"] ) {
NSFileManager *fileManager = [NSFileManager defaultManager];
// Create the URL for the destination folder and ensure it exists.
NSURL *applicationFilesDirectory = [self applicationFilesDirectory];
NSURL *url = [applicationFilesDirectory URLByAppendingPathComponent:@"documents"];
BOOL isDir;
if (!([fileManager fileExistsAtPath:[url path] isDirectory:&isDir] && isDir)) {
NSError * error = nil;
[ fileManager createDirectoryAtURL:url withIntermediateDirectories: YES attributes:nil error:&error];
if (error) {
[[NSApplication sharedApplication] presentError:error];
}
}
BOOL ok = false;
// locate the mailbox path....
NSString *mailboxpath = [pboard stringForType:@"MV Super-secret message transfer pasteboard type"];
NSLog(@"Mailboxpath: %@", mailboxpath);
NSString * codedFolder = [self FindCodedFolderInMailbox:mailboxpath];
if (codedFolder) {
NSString * codedpath = [NSString stringWithFormat:@"file://%@/%@/Data", mailboxpath, codedFolder];
NSURL * mb1 = [NSURL URLWithString:codedpath];
NSLog(@"Directory:%@", mb1);
NSArray *msgArray = [pboard propertyListForType:@"Super-secret Automator pasteboard type"];
if (msgArray) {
for (NSDictionary *msg in msgArray) {
// Locate the message....
NSNumber * msgID = [msg valueForKey:@"id"];
NSLog(@"Melding(%@):%@", msgID, msg);
NSString * filename = [NSString stringWithFormat:@"%@.emlx", msgID];
// second and first letter of id
NSString * idSec = [[msgID stringValue]substringWithRange:(NSRange){1, 1}];
NSString * idFirst = [[msgID stringValue]substringWithRange:(NSRange){0, 1}];
NSString * subpath = [NSString stringWithFormat:@"%@/%@/Messages/%@",idSec, idFirst, filename];
NSURL * thisFilePath = [mb1 URLByAppendingPathComponent:subpath];
if ([fileManager fileExistsAtPath:[thisFilePath path]]) {
NSURL *destpath = [url URLByAppendingPathComponent:filename];
NSError * error = nil;
[fileManager copyItemAtURL:thisFilePath toURL:destpath error:&error];
if (error) {
[[NSApplication sharedApplication]presentError:error];
} else {
[self ParseEmlMessageforPath:[destpath path] filename:filename];
}
}
}
}
}
我们开始吧...:-)
关于objective-c - 将电子邮件从 mail.app 放入 NSWindow 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17859184/
我想在 DNN 模块中完成注册过程后发送电子邮件。当我搜索时,我发现 dnn 中有一个内置的邮件类。但它包含两个方法 - SendEmail 和 SendMail。这两者有什么区别?在这种情况下我必须
我有一个非常特殊的要求 我正在使用 Java Mail API 访问用户的收件箱。可以说是投诉服务信箱。用户通过向该地址发送电子邮件来注册投诉。我从收件箱中提取每封电子邮件并创建一个新的投诉。我的问题
我正在使用64位MS SQL Server 2008 R2 SP2 Express版。 我没有访问数据库邮件设置向导的权限,但是Binn目录包含DatabaseMail.exe(v10.50.1660
我正在为使用 Mail::queue 函数发送电子邮件的代码编写单元测试,如文档中的代码:https://laravel.com/docs/5.4/mocking#mail-fake 我的测试: /*
我试图使用 java 邮件 API 阅读我的 gmail 帐户中的邮件。这是代码: import java.util.*; import java.io.*; import java.awt.*; i
我已经看到关于此主题的数千个类似问题。可以肯定的是,我知道 SO 中的“标记为重复问题”。 但是,从 PHP mail() 函数获取雅虎收件箱电子邮件,简单来说,如何或必须做什么仍然不清楚。 在 Ya
我正在尝试从 php 向 gmail 帐户发送电子邮件。我的笔记本电脑上有以下设置: Windows 8 Internet connection XAMPP 1.7.4, PHP Version 5.
使用过时的 System.Web.Mail 发送电子邮件工作正常,这是代码片段: Public Shared Sub send(ByVal recipent As String, ByVal fro
有没有办法从 Java Mail API 中获取邮件是否被标记为重要?我正在使用 Gmail 帐户进行连接。提前致谢。 最佳答案 不同的邮件程序使用不同的方式来表明邮件“重要”。有些使用 X-Prio
我正在编写一个 PHP 邮件函数,一些示例有 @mail(...),而其他示例只有 mail(...)。 有什么区别,最好使用哪个? 干杯 最佳答案 @ 抑制所有警告/错误,mail() 函数可能会抛
我一直在开发一个连接到 Yahoo 邮件的 Java 应用程序,使用户能够通过他们的 Yahoo 电子邮件进行搜索。 最近,Yahoo 突然(仅提前 5 周通知)停止了我们正在使用并且运行良好的 Ya
我想发送邮件为用户重置密码,如果他忘记了密码,我会收到此错误: org.springframework.mail.MailSendException: Mail server connection f
所以,我的问题如下:我有一个用 Java 编写的邮件客户端,在使用 POP3 检查邮件后,无法通过 SMTP 发送邮件。 我捕获的异常表明传输协议(protocol) = null。 代码工作正常,因
我正在尝试使用 ruby mail gem 检索电子邮件,在示例中它说 Mail.last将检索最后一封未读电子邮件 https://github.com/mikel/mail#getting-e
在我的系统中,我应该在查看列表后发送通知邮件我正在使用 DNN 有我使用的代码 private void SendEmailNotification() { DotNetNuk
我创建了一个.sh脚本,并将结果记录在一个文件中,执行后我会尝试将文件内容作为mail正文发送。 这是我运行的命令: sh update.sh >> update.$(date +"%Y-%m-%d:
我使用 AE.NET.Mail 来阅读我的电子邮件正文。 但是那些尸体都是空的! 我的代码如下: // Connect to the IMAP server. The 'true' param
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我在尝试发送带有文件附件的电子邮件时遇到错误: javax.mail.internet.ParseException: Expected '/', got files at javax.mai
我在IntelliJ IDEA中导入了一个maven项目后,pom.xml文件有两个错误: "Failed to read artifact descriptor for javax.mail:mai
我是一名优秀的程序员,十分优秀!