Ja też się tym interesowałem, więc przez dwa dni pracowałem nad wersją wsteczną funkcji "Zawartość e-mailowa tej strony" w programie Safari, a ja działałem.
UPDATE: poprawiłem kod i umieścić go na GitHub
- (void)mailWebArchive:(WebArchive *)webArchive title:(NSString *)aTitle URL:(NSString *)aURL {
NSString *bundleID = @"com.apple.mail";
NSData* targetBundleID = [bundleID dataUsingEncoding:NSUTF8StringEncoding];
NSAppleEventDescriptor *targetDescriptor = nil;
NSAppleEventDescriptor *appleEvent = nil;
targetDescriptor = [NSAppleEventDescriptor descriptorWithDescriptorType:typeApplicationBundleID
data:targetBundleID];
appleEvent = [NSAppleEventDescriptor appleEventWithEventClass:'mail'
eventID:'mlpg'
targetDescriptor:targetDescriptor
returnID:kAutoGenerateReturnID
transactionID:kAnyTransactionID];
[appleEvent setParamDescriptor:[NSAppleEventDescriptor descriptorWithDescriptorType:'tdta'
data:[webArchive data]]
forKeyword:'----'];
[appleEvent setParamDescriptor:[NSAppleEventDescriptor descriptorWithString:aTitle]
forKeyword:'urln'];
[appleEvent setParamDescriptor:[NSAppleEventDescriptor descriptorWithString:aURL]
forKeyword:'url '];
NSAppleEventDescriptor *replyDescriptor = nil;
NSAppleEventDescriptor *errorDescriptor = nil;
AEDesc reply = { typeNull, NULL };
// Send the AppleEvent
OSStatus status = AESendMessage([appleEvent aeDesc],
&reply,
kAEWaitReply,
kAEDefaultTimeout);
if(status == noErr)
{
replyDescriptor = [[[NSAppleEventDescriptor alloc] initWithAEDescNoCopy:&reply] autorelease];
errorDescriptor = [replyDescriptor paramDescriptorForKeyword:keyErrorNumber];
if(errorDescriptor != nil)
status = [errorDescriptor int32Value];
if(status != noErr)
NSLog(@"%s error %d", _cmd, status);
}
}
Ten kod nie sprawdza, czy Poczta działa, więc to tylko działać, gdy poczta jest już uruchomiona.
Pro strona tego podejścia, która działa ze wszystkimi klientami poczty e-mail, które implementują MailLinkSupported i MailPageSupported. Zobacz QA1722.
Wadą jest to, że nie można ustawić odbiorców tak jak z mailto
. W tym celu jedynym rozwiązaniem jest Mostek Skryptów. Zobacz zmodyfikowane SBSendEmail sample.
Kilka źródeł: http://cocoaheads.byu.edu/resources/email –
Jakieś wiadomości na ten temat? –