Canon of the Mass
Therefore, we humbly pray and beseech Thee, most merciful Father, through Jesus Christ Thy Son, Our Lord, to receive and to bless these `†´ gifts, these `†´ presents, these `†´ holy unspotted sacrifices, which we offer up to Thee, in the first place, for Thy holy Catholic Church, that it may please Thee to grant her peace, to guard, unite, and guide her, throughout the world: as also for Thy servant N., our Pope, and N., our Bishop, and for all who are orthodox in belief and who profess the Catholic and apostolic faith.
Notice that the unspotted sacrifice, Our Lord Jesus Christ, is offered up for the Holy Catholic Church, which is itself spotless as is Our Lord. The Holy Catholic Church is composed of those Catholics in a state of Grace, who are themselves spotless. The mass is also offered for the human element of the Church, which may not be spotless at the time, but are still members; the "Pope, and N., our Bishop, and for all who are orthodox in belief and who profess the Catholic and apostolic faith".
Those that are not orthodox in belief and do not profess the Catholic and apostolic faith, are not members of the Church, even if they have the title of pope and bishop.