Depends on the answering machine... There are some that will do this... most won't... but there are seperate 'boxes' you can get (I think one commercial one is The Phone Zapper) that'll do it...
Or if you have a full voice modem in yer PC, there are plenty of programs you can download that'll do all this and much much more!