With e-mail, it would have to be sent from that person's computer. Letters from GMail, Hotmail, Yahoo mail or any other web-based service are sent from the web server and there is no way you can know where the actual sender was.
With instant messaging, you would have to do some direct file transfer or a direct webcam session or direct voice chat to get the IP of the other end.