gpt4 book ai didi

cocoa - 使用 Apple Scripting Bridge 和 Mail 发送附件会导致消息背景变黑

转载 作者:行者123 更新时间:2023-12-03 17:17:22 25 4
gpt4 key购买 nike

当我使用 Apple Scripting Bridge 发送带有附件的消息时,消息的背景设置为黑色,这是一个问题,因为文本也是黑色的。有问题的代码是:

MailApplication *mail = [SBApplication applicationWithBundleIdentifier:@"com.apple.Mail"];

/* create a new outgoing message object */
MailOutgoingMessage *emailMessage =
[[[mail classForScriptingClass:@"outgoing message"] alloc]
initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
emailSubject, @"subject",
[self composeEmailBody], @"content", nil]];

/* add the object to the mail app */
[[mail outgoingMessages] addObject: emailMessage];

/* set the sender, show the message */
emailMessage.sender = [NSString stringWithFormat:@"%@ <%@>",[[[mail accounts] objectAtIndex:playerOptions.mailAccount] fullName],[[[[mail accounts] objectAtIndex:playerOptions.mailAccount] emailAddresses] objectAtIndex:0]];
emailMessage.visible = YES;

/* create a new recipient and add it to the recipients list */
MailToRecipient *theRecipient =
[[[mail classForScriptingClass:@"to recipient"] alloc]
initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
opponentEmail, @"address",
nil]];
[emailMessage.toRecipients addObject: theRecipient];

/* add an attachment, if one was specified */
if ( [playerInfo.gameFile length] > 0 ) {

/* create an attachment object */
MailAttachment *theAttachment = [[[mail classForScriptingClass:@"attachment"] alloc] initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
playerInfo.gameFile, @"fileName", nil]];

/* add it to the list of attachments */
[[emailMessage.content attachments] addObject: theAttachment];
}
/* send the message */
[emailMessage send];

背景颜色的实际更改发生在倒数第二行,即:

[[emailMessage.content attachments] addObject: theAttachment];

上面的代码部分基本上取自 Apple 的 SBSendMail 示例代码。在这个阶段,我实际上只进行了与应用程序中的数据集成所需的更改。如果我在从 Apple 新鲜下载后构建并运行 SBSendMail 示例,则执行同一行后消息背景也会更改为黑色。附加哪种类型的文件、位于何处、使用哪台计算机或操作系统似乎并不重要。

这可能是 Apple 脚本桥中的一个错误,但有人遇到过这个问题并找到解决方案吗?另外,有人知道是否可以使用脚本桥更改 MailOutgoingMessage 实例的背景颜色吗?

最佳答案

我不认为问题出在你的代码中。我认为这是最近出现的一个错误。对这个问题的快速谷歌搜索发现了这个:http://discussions.apple.com/thread.jspa?threadID=2453797&start=0&tstart=0

关于cocoa - 使用 Apple Scripting Bridge 和 Mail 发送附件会导致消息背景变黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3050525/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com