It depends. You would have to look to the written terms of the easement agreement, if it is in writing. Also, if both units were foreclosed and camed under the same ownership, there is a potential for merger, a legal term whereby the easement is extinguished because the same owner owns both the burdened land and the benefitted land. From what you are describing, it sounds like a condominium is involved and that would also require looking to determine if the easement was properly created in the first place. You should take all of the documents I've mentioned and any other relevant materials to a real estate attorney to determined the parties' rights and obligations.
This "answer" is for information purposes only and is not intended as legal advice or to create an attorney-client relationship.
I think that any attorney who is going to attempt to answer this question, would have to review the title exam as well. It is quite possible that the easement is considered abandoned if both units got foreclosed on. Also relevant is how the easement was created. If it was done by an amendment to the Master Deed, then I belive it would permament, but if it was just an agreement between two owners then the mortage company may not be subject to it.
I agree with the comments above. The two key issues are likely to be (1) whether the easement was extinguished in the foreclosure process, and (2) the express wording of the easement itself. The answer to the first question will ultimately depend on whether Unit B's interest, which is the "dominant" interest was included in the foreclosure of Unit A's title. If so, Unit B's interest may have been extinguished in the sheriff's sale and the buyer of Unit A would have obtained title free and clear of any such easement. As for the wording of the easement itself, a title report should contain the document in the chain of title creating that interest and should also reflect whether the interest was extinguished or modified in any way. You should consult with an experienced real estate attorney in your state to become fully informed as to the extent of any remaining rights.
The information you obtain at this site is not, nor is it intended to be, legal advice. You should consult an attorney for advice regarding your individual situation.