I am so sorry! that is so sad.
I know what it feels like to lose a pet..it hurts. the milk could've been the reason, but please dont blame yourself! there was nothing you could do, and whats happened has happened, so blaming yourself wouldn't make it any better. the other reason could've been (because you said) that there was something stuck in his anus. This could've prevented him from going to the bathroom, and that could've been what happened. whatever the cause, I hope you feel better. He is probably in hammy heaven right now, and he's keeping an eye on you. wait a few weeks to heal, and then maybe you can think of getting another hamster to take care of, and that might help you heal, having somthing else to care for. altho I know no other pet could take the place of him, but another pet could help, so that you have something else to love.
I hope you will feel better.