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 インスタンスの背景色を変更できるかどうかを知っている人はいますか?