have a look at Wiki for asterisk + odbc storage. The database for storing entire voicemail messages can be stored on a local or a remote database. Then you can do whatever you want with it. You will have to recompile asterisk by turning on ODBC storage. It's all there on the Wiki