I find that being honest can get you a ways as well. If you can determine that the occupants are tenants, then they probably know that the home is under foreclosure. Stating that you are interested in buying the house as an investment property are are willing to keep the tenants may open the door to an inspection - especially if the tenants do not want to move and if they do, they probably could careless if you look at the place anyway.
If the occupants are the property owners, they also know that the home is up for foreclosure. As a concerned investor, you are wondering if there was someway that you could help them. Admitting that it is awkward and emotionally taxing to talk about, but that maybe you could help them get out from under the foreclosure and move on with their life.
Both strategies require a friendly approach rather than a "I'm here to buy this property" outlook.