you should consult a real estate attorney who can best advise you.
Each state has laws that govern the foreclosure process, including the notices a lender must post publicly, the owner's options for bringing the loan current and avoiding foreclosure, and the timeline and process for selling the property.
Normally, a foreclosure is treated as a sale. You "sold" the property to the bank, and the price is the amount the bank realized at auction (which might have left you with a deficiency of course.)
It sounds like this was business property, since I don't think that question will come up for the sale or foreclosure of a personal home. If this was business property, you may owe recapture tax on depreciation you previously took, even if the property was foreclosed at a loss. You may want professional tax advice.