0

我正在将我的项目转移到 ARC 并发生崩溃

2012-04-04 21:08:32.438 callsfreecall[39756:780b] warning: <MailApplication @0x87bf27f0: application "Mail" (764)> has no class for scripting class "outgoing message".
2012-04-04 21:08:32.438 callsfreecall[39756:780b] -[MailApplication outgoingMessages]: unrecognized selector sent to instance 0x7ff987bf27f0

我不知道,我该如何解决。

代码是标准的:

NSString *to = [toForCheck stringByReplacingOccurrencesOfString:@" " withString:@""];
/* create a Scripting Bridge object for talking to the Mail application */
MailApplication *mail = [SBApplication
                         applicationWithBundleIdentifier:@"com.apple.Mail"];

/* create a new outgoing message object */

// NSData *data = [NSData dataWithContentsOfFile:@"/Users/alex/test.rtf"];
//NSMutableDictionary *attrib = [[NSMutableDictionary alloc] initWithCapacity:0]; 
//NSAttributedString *attributed = [[NSAttributedString alloc] initWithPath:@"/Users/alex/test.rtf" documentAttributes:nil];

MailOutgoingMessage *emailMessage =
[[[mail classForScriptingClass:@"outgoing message"] alloc]
 initWithProperties:
 [NSDictionary dictionaryWithObjectsAndKeys:
  subject, @"subject",
  content , @"content",
  nil]];

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

/* set the sender, show the message */
emailMessage.sender = from;
emailMessage.visible = NO;

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


/* add an attachment, if one was specified */
for (NSString *attachmentFilePath in filePaths)
{
    //NSString *attachmentFilePath = filePath;
    if ( [attachmentFilePath length] > 0 ) {
        /* create an attachment object */
        MailAttachment *theAttachment = [[[mail
                                           classForScriptingClass:@"attachment"] alloc]
                                         initWithProperties:
                                         [NSDictionary dictionaryWithObjectsAndKeys:
                                          attachmentFilePath, @"fileName",
                                          nil]];

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

0 回答 0