If you can still smell mildew, you still have LIVE mildew. Bleach is one of the few things that really kills it. Of course then you'll smell the bleach, and it is easy to use too much bleach. Make sure you rinse it well, if you can still smell bleach when you are done, it will still be in there attacking the foam.
Do not use ammonia--that attacks latex and breaks it down.
If there's someplace near you that does carpet cleaning in a store? They have machines that run the carpet (or the foam) through rollers with a steam bath, that's really effective at cleaning. And drying--which will prevent the mildew from restarting.