Mail count with Automator? I am trying to create file containing different statistics about things such as email count and such things, trial here: this proto returns empty file, not sure why. How can count the amount of emails with Automator under OS X?
Probably easier to do this with AppleScript, which you can then use in an Automator action if you like.

tell application "Mail"
    set myAccount to "Gmail"
    set mailboxList to {"INBOX", "[Gmail]/Sent Mail"}
    set messageCount to 0
    repeat with _mailbox in mailboxList
        set messageCount to messageCount + (count of messages in mailbox _mailbox of account myAccount)
    end repeat
    get messageCount
end tell


That will return the number of messages in each mailbox you specify in the list on line two. If use it in an Automator action, it will pass that value along to whatever the next action is.

You'll need to change the myAccount line to whatever your account is named in preferences.

To get the specific mailbox names, run tell application "Mail" to get mailboxes of account "Gmail" in AppleScript editor. You can then add them to the mailboxList in line 3, make sure they're quoted, and each entry is separated by a comma.