Re: email
Re: email
- Subject: Re: email
- From: has <email@hidden>
- Date: Sun, 1 Jun 2008 12:00:11 +0100
Chris Page wrote:
Importing messages from Mail via AppleScript may not be fast enough
my highly scientific estimate* is "a couple of messages" a second.
Importing someone's entire mail archive would take a long time.
I just did a test and it's quite fast if you ask for all the messages
at once:
[...]
I'm seeing average times of one to two milliseconds per message (e.g.,
7 seconds for a mailbox with 4,660 messages) on a 2.5GHz Quad G5.
Don't forget to process the standard mailboxes as well - for some
reason they're presented as properties rather than elements of Mail's
'application' object, so you have to deal with them separately.
Also, one caveat with getting entire messages: if you've got any with
large attachments, that will slow things down, e.g. OMM [1]:
Importing 9 messages from Drafts
Total: 0.4956 Average: 0.0551
Importing 184 messages from Inbox
Total: 2.6736 Average: 0.0145
No messages found in Outbox
Importing 1609 messages from Sent
Total: 59.5408 Average: 0.0370 <-- some attachments in my Sent mailbox
Importing 122 messages from appscript
Total: 0.3417 Average: 0.0028
Importing 66 messages from personal
Total: 0.6233 Average: 0.0094
Importing 1139 messages from read
Total: 8.2016 Average: 0.0072
Importing 73 messages from ruby
Total: 0.8477 Average: 0.0116
Importing 237 messages from work
Total: 67.6088 Average: 0.2853 <-- lots of attachments in my work
mailbox
No messages found in ToDos
No messages found in Notes
No messages found in Outbox
HTH
has
[1] Timing code (using appscript, natch):
//====================================================================
#import "MLGlue/MLGlue.h"
// To generate Mail glue: osaglue -o MLGlue -p ML Mail
void GetMessagesFromMailbox(MLReference *box, NSError **error) {
int n;
NSTimeInterval startTime, elapsedTime;
n = [[[[box messages] count] sendWithError: error] intValue];
if (*error) return;
if (n) {
printf("Importing %i messages from %s\n", n, [[[[box name] get]
send] UTF8String]);
startTime = [NSDate timeIntervalSinceReferenceDate];
[[[[box messages] source] get] sendWithError: error];
if (*error) return;
elapsedTime = [NSDate timeIntervalSinceReferenceDate] - startTime;
if (n == 0) n = 1;
printf("\tTotal: %.4f Average: %.4f\n", elapsedTime, elapsedTime / n);
} else
printf("No messages found in %s\n", [[[[box name] get] send]
UTF8String]);
}
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSError *error;
int i, err = 0;
MLApplication *mail = [[MLApplication alloc] initWithBundleID:
@"com.apple.mail"];
// standard mailboxes
GetMessagesFromMailbox([mail draftsMailbox], &error);
if (error) goto fail;
GetMessagesFromMailbox([mail inbox], &error);
if (error) goto fail;
GetMessagesFromMailbox([mail outbox], &error);
if (error) goto fail;
GetMessagesFromMailbox([mail sentMailbox], &error);
if (error) goto fail;
// user-defined mailboxes
int boxCount = [[[[mail mailboxes] count] sendWithError: &error]
intValue];
if (error) goto fail;
for (i = 0; i < boxCount; i++) {
GetMessagesFromMailbox([[mail mailboxes] at: i], &error);
if (error) goto fail;
}
fail:
if (error) NSLog(@"An error occurred: %@", error);
err = [error code];
[mail release];
[pool drain];
return err;
}
//====================================================================
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden