Sounds like a job for BBEdit (www.barebones.com). It has a pretty powerful set of regular expression searching tied together with multi-file searching and duplicate processing.
As I recall Apple Mail places each message into a separate file within a folder structure that is displayed on-screen. BBEdit could rip through all of the folders and subfolders first to isolate lines where an email address occurs, then you can copy those lines to a new file, process that to eliminate anything but the email addresses, sort the result and run a process to remove duplicate lines leaving a single occurrence. That should be a good start to getting what you want.
The hardest part is to get a regular expression that actually identifies an email address. I tried a quick Google search and someone far more interested in covering all of the bases came up with a long explanation at http://www.regular-expressions.info/email.html. At a glance, I believe BBEdit would likely accept the way in which these regex are written.
-- Drew Tenenholz
You could write a custom AppleScript to go through all the emails and save the email addresses in a text file. I haven't done it before but shouldn't be too difficult.
Each mailbox in Apple Mail can be exported (menu Mailbox>Export Mailbox…) in a .mbox format. When you rename the extension of inbox.mbox to inbox.txt, it produces a folder. Inside the folder are two files—table of contents and mbox—both of which can be read in TextEdit. However, it looks like a challenge to parse the @addresses from this.
If you add your email addresses to the Address Book... you can use "Address Book Exporter"
If you choose "Previous Recipients" from the Window menu, you can select all the addresses and copy & paste them to excel or save as a text document which can be imported.
Other than that Applescript will allow you to loop thru messages and capture the addresses.
I suggest you look at 'Mail Archiver X', which can copy emails out of Apple Mail, into a FileMaker database. From there you can easily extract the email addresses and make a unique list.
Best wishes - Alan Stirling, London UK.
One thing to consider is if this is a one time project or you want to do this often. If you want to do this often, you might look into one of the FileMaker mail plugins that supports IMAP and can pull all of the mail into FileMaker for you to analyze to your hearts content and can do this as often as you want to run a script searching through everything.