For Exchange 2010, use powershell
Exports a lot of information
get-mailboxserver | get-mailbox | export-csv FILENAME.CSV
Exports less information, use above to see what fields can be included
get-mailbox -resultsize unlimited -recipienttypedetails usermailbox | get-user | select-object firstname,lastname,windowsemailaddress | export-csv FILENAME.CSV