Tôi cũng quan tâm đến điều này, vì vậy, hai ngày kỹ thuật đảo ngược nội dung thư của Safaris 'Nội dung của trang này' và tôi nhận được nó hoạt động.
UPDATE: tôi cải thiện mã và đặt nó trên 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);
}
}
Mã này không kiểm tra xem Thư đang chạy, vì vậy nó chỉ làm việc khi Thư đã được bắt đầu.
Mặt chuyên nghiệp của phương pháp này hoạt động với tất cả ứng dụng email thực hiện MailLinkSupported và MailPageSupported. Xem QA1722.
Nhược điểm là bạn không thể đặt người nhận như với mailto
. Đối với điều này, Scripting Bridge có vẻ là giải pháp duy nhất. Xem sửa đổi này SBSendEmail sample.
Một vài tài nguyên: http://cocoaheads.byu.edu/resources/email –
Bất kỳ tin tức nào về vấn đề này? –