无法从草稿发送附件(Mail.app)
我正在尝试发送使用 Mail.app 创建的草稿。
由于草稿没有发送方法,我必须从草稿中获取所有内容,并用它创建一封新电子邮件。应该没问题,但是...附件无法通过。
我正在使用这个:
outgoing.content = message.content;
其中传出是我正在创建的消息,消息是我正在阅读的草稿。
我尝试循环遍历消息的附件并手动添加它们,但我总是得到这样的信息:
*** -[SBElementArray addObject:]: can't add an object that already exists.
这就是我循环遍历它们的方式:
for (int i=0; i<[message.content.attachments count]; i++) {
MailAttachment *anAttachment = [message.content.attachments objectAtIndex:i];
if (![outgoing.content.attachments containsObject:anAttachment]) {
NSLog(@"File Path: %@", anAttachment.fileName);
MailAttachment *newAttachment = anAttachment;
[outgoing.content.attachments addObject:newAttachment];
}
}
值得注意的是,无论如何,文件路径 NSLog 始终显示为 (null)。
将不胜感激这里的任何帮助。
I am trying to send a draft created with Mail.app.
As drafts have no send method, I'm having to get all the content from the draft, and create a new e-mail with it. That should be ok, but... Attachments aren't getting through.
I am using this:
outgoing.content = message.content;
Where outgoing is the message I am creating and message is the draft I am reading from.
I tried looping through the attachments of the message and adding them manually but I always get this:
*** -[SBElementArray addObject:]: can't add an object that already exists.
This is how I am looping through them:
for (int i=0; i<[message.content.attachments count]; i++) {
MailAttachment *anAttachment = [message.content.attachments objectAtIndex:i];
if (![outgoing.content.attachments containsObject:anAttachment]) {
NSLog(@"File Path: %@", anAttachment.fileName);
MailAttachment *newAttachment = anAttachment;
[outgoing.content.attachments addObject:newAttachment];
}
}
It should be worth noting that the File Path NSLog always comes out as (null), no matter what.
Would appreciate any help here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据我的研究,Mail.app 的 AppleScript/ScriptingBridge API 在读取消息和获取其内容方面几乎没有问题。
From my research, Mail.app's AppleScript/ScriptingBridge API is pretty much broken when it comes to reading messages and getting its contents.