There Is No Salvation Outside of the Church
The Church has always taught that there is no salvation outside of the Church (Extra Ecclesiam nulla salus). This is a dogma of the Faith and must be believed. It has been affirmed by Popes and saints. For instance, Pope Eugene IV in Cantate Domino in 1441 AD declares:
"The most Holy Roman Church firmly believes, professes, and preaches that none of those existing outside the Catholic Church, not only pagans, but also Jews and heretics and schismatics, can have a share in life eternal; but that they will go into the eternal fire which was prepared for the devil and his angels unless before death they are joined with Her; and that so important is the unity of this ecclesiastical body that only those remaining within this unity can profit by the sacraments of the Church unto salvation, and they alone can receive an eternal recompense for their fasts, their almsgivings, their other works of Christian piety and the duties of a Christian soldier. No one, let his almsgiving be as great as it may, no one, even if he pours out his blood for the Name of Christ, can be saved, unless he remains within the bosom and the unity of the Catholic Church."
And St. Augustine earlier wrote: "No one can find salvation except in the Catholic Church. Outside the Church, you can find everything except salvation. You can have dignities, you can have Sacraments, you can sing "'Alleluia,' answer 'Amen,' have the Gospels, have faith in the name of the Father, the Son, and the Holy Ghost, and preach it, too. But never can you find salvation except in the Catholic Church."
Praying for the Souls of Non-Catholics Is Not Contrary to Extra Ecclesiam Nulla Salus
The Church encourages and allows private prayer for anyone, even those who died as non-Catholics since we do not know the state of their soul at the moment of death. Miraculous conversions have been won before by people who seemed to be unconscious but who, through miracles, were given the grace to choose the Faith at the moment of death. It does happen and thus we must pray for the salvation of all souls, especially for their conversion to salvation at the moment of death. And since God sees our prayers outside of time, we can pray for anyone's last-minute conversion, even long after their death. In effect, the soul will then truly die as a Catholic even if in the eyes of the world they appeared to die separated from the Faith. This is my particular prayer for Queen Elizabeth II.
The Church Permits Prayers for the Dead for Everyone
The Catholic Encyclopedia makes this clear:
"There is no restriction by Divine or ecclesiastical law as to those of the dead for whom private prayer may be offered — except that they may not be offered formally either for the blessed in heaven or for the damned. Not only for the faithful who have died in external communion with the Church, but for deceased non-Catholics, even the unbaptized, who may have died in the state of grace, one is free to offer his personal prayers and good works; nor does the Church's prohibition of her public offices for those who have died out of external communion with her affect the strictly personal element in her minister's acts. For all such she prohibits the public offering of the Sacrifice of the Mass (and of other liturgical offices); but theologians commonly teach that a priest is not forbidden to offer the Mass in private for the repose of the soul of any one who, judging by probable evidence, may be presumed to have died in faith and grace, provided, at least, he does not say the special requiem Mass with the special prayer in which the deceased is named, since this would give the offering a public and official character."
It is true that the offering of prayers and sacrifices for the souls of those in Hell is of no use. But since we do not know the state of a soul at death, we can nevertheless in an act of charity offer prayers for all of the departed. Only God judges the heart and knows the state of the soul at death (cf. 1 Samuel 16:7).
Requiem Masses Are Not Permitted for Non-Catholics
While we may and should pray for the salvation of all mankind, we do know that the public offering of the Holy Sacrifice of the Mass for the souls of non-Catholics is not permitted. Canon 1240 in the 1917 Code explicitly forbid the privilege of ecclesiastical burial rites to anyone who died as a known member of a heretical sect. Even if this distinction is not mentioned in the modernist 1983 Code, we know the 1917 Code expressed the wisdom of centuries of Catholic dogma.
This is similarly affirmed, with the distinction of public versus private prayer, in the American Ecclesiastical Review from 1896 which answers the question of whether a priest may perform funeral rites over the dead by answering:
"No, a priest cannot lawfully perform the ceremony of burial for a deceased non-Catholic or one who, having been baptized a Catholic, has defected. The presence of a priest officiating at the burial cannot be construed as a civil function, for the act of consigning a person to his grave requires no authorized witness, like the contract of marriage. The burial service of the Catholic ritual is a religious function in which we cannot share with those who deny the truth of our faith and worship, for we should implicitly, by our service, sanction the protest of the deceased against the Catholic religion. Of course, there are cases where a priest may and should bury those who are not of his faith, just as he may pray for them privately."
This is the distinction between public and private prayer. Hence, the words of Pope St. Gregory II in 731 AD are referring to public worship:
“You ask for advice on the lawfulness of making offerings for the dead. The teaching of the Church is this – that every man should make offerings for those who died as true Christians [Catholics]… But he is not allowed to do so for those who die in a state of sin even if they were Christians.”
Conclusion
May the souls of all the faithful departed rest in peace. There is no salvation outside of the Church. But God alone knows the state of a soul at death. Thus in our charity and love for all man - since we desire all to be saved - we continue to pour forth private prayers for the conversion and salvation and mitigation of Purgatory for everyone, even those who in our eyes died outside the Church but who may have made a perfect act of contrition or who became Catholic by divine intervention right before the moment of God.
God have mercy on them all, especially on the soul of Her Majesty Queen Elizabeth II and her ancestors. And may her heirs return the British Crown to public reconciliation with the Roman Catholic Church and the See of Peter.