Использование Cocoa
Scripting Bridge для отправки электронной почты, как я могу добавить больше одного приложения.Использование Cocoa Scripting Bridge для отправки электронной почты
Вот мой код:
MailApplication *mail = [SBApplication applicationWithBundleIdentifier:@"com.apple.Mail"];
emailMessageL = [[[mail classForScriptingClass:@"outgoing message"] alloc] initWithProperties:
NSDictionary dictionaryWithObjectsAndKeys: [self.subjectField stringValue], @"subject", [self.messageContent stringValue], @"content", nil]];
[[mail outgoingMessages] addObject: emailMessageL];
emailMessageL.sender = [self.fromField stringValue];
emailMessageL.visible = YES;
if ([mail lastError] != nil)
return;
MailToRecipient *theRecipient = [[[mail classForScriptingClass:@"to recipient"] alloc] initWithProperties:
[NSDictionary dictionaryWithObjectsAndKeys:
[self.toField stringValue], @"address",
nil]];
[emailMessageL.toRecipients addObject: theRecipient];
if ([mail lastError] != nil)
return;
NSString *attachmentFilePath = aStrUrl ;
if ([attachmentFilePath length] > 0)
{
MailAttachment *theAttachment;
theAttachment = [[[mail classForScriptingClass:@"attachment"] alloc] initWithProperties: [NSDictionary dictionaryWithObjectsAndKeys: [[NSURL URLWithString:attachmentFilePath] path], @"fileName", nil]];
[[emailMessageL.content attachments] addObject: theAttachment];
if ([mail lastError] != nil)
return;
}
Большое спасибо за помощь. Проблема полностью решена. Грэзи, Джанни. – Gianni