Is there an Apple Script that enables the user to extract the total count of mails from each mailbox in Mac Mail
This is the output I would like to generate
Mailbox name # of emails
Project 1 65
Project 2 89
Project 3 21
Mac mini
This is the output I would like to generate
Mailbox name # of emails
Project 1 65
Project 2 89
Project 3 21
Mac mini
Hello
You may try something like this.
_main() on _main() script o property |MAILBOX_PATH| : false -- true to get mailbox path, false to get mailbox name property pp : {} property qq : {{"Mailbox", "# of emails"}} tell application "Mail" set pp to mailboxes repeat with p in my pp tell p's contents if |MAILBOX_PATH| then set my qq's end to {(it as record)'s «class seld», count messages} else set my qq's end to {name, count messages} end if end tell end repeat end tell set t to _array2text(qq, tab, linefeed) --set the clipboard to t return t end script tell o to run end _main on _array2text(aa, fs, rs) (* list aa : source 2d-array string fs : column separator (field separator) string rs : row separator (record separator) return string : text representation of aa *) script o property pp : aa property qq : {} repeat with p in my pp set end of my qq to _join(p's contents, fs) end repeat return _join(qq, rs) end script tell o to run end _array2text on _join(tt, d) (* list tt : source list string d : separator return string : tt joined with d *) local astid0, t try set {astid0, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {} & d} set t to "" & tt set AppleScript's text item delimiters to astid0 on error errs number errn set AppleScript's text item delimiters to astid0 error errs number errn end try return t end _join
Briefly tested with Mail 4.6 under OS X 10.6.8.
Good luck,
H
Hello
You may try something like this.
_main() on _main() script o property |MAILBOX_PATH| : false -- true to get mailbox path, false to get mailbox name property pp : {} property qq : {{"Mailbox", "# of emails"}} tell application "Mail" set pp to mailboxes repeat with p in my pp tell p's contents if |MAILBOX_PATH| then set my qq's end to {(it as record)'s «class seld», count messages} else set my qq's end to {name, count messages} end if end tell end repeat end tell set t to _array2text(qq, tab, linefeed) --set the clipboard to t return t end script tell o to run end _main on _array2text(aa, fs, rs) (* list aa : source 2d-array string fs : column separator (field separator) string rs : row separator (record separator) return string : text representation of aa *) script o property pp : aa property qq : {} repeat with p in my pp set end of my qq to _join(p's contents, fs) end repeat return _join(qq, rs) end script tell o to run end _array2text on _join(tt, d) (* list tt : source list string d : separator return string : tt joined with d *) local astid0, t try set {astid0, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {} & d} set t to "" & tt set AppleScript's text item delimiters to astid0 on error errs number errn set AppleScript's text item delimiters to astid0 error errs number errn end try return t end _join
Briefly tested with Mail 4.6 under OS X 10.6.8.
Good luck,
H
Is there an Apple Script that enables the user to extract the total count of mails from each mailbox in Mac Mail