I answer that, There are two things to be weighed regarding the aforesaid movements: one on account of which they necessarily prevent a man from receiving this sacrament; the other, on account of which they do so, not of necessity, but from a sense of propriety.
Mortal sin alone necessarily prevents anyone from partaking of this sacrament: and although these movements during sleep, considered in themselves, cannot be a mortal sin, nevertheless, owing to their cause, they have mortal sin connected with them; which cause, therefore, must be investigated. Sometimes they are due to an external spiritual cause, viz. the deception of the demons, who can stir up phantasms, as was stated in the FP, Question [111], Article [3], through the apparition of which, these movements occasionally follow. Sometimes they are due to an internal spiritual cause, such as previous thoughts. At other times they arise from some internal corporeal cause, as from abundance or weakness of nature, or even from surfeit of meat or drink. Now every one of these three causes can be without sin at all, or else with venial sin, or with mortal sin. If it be without sin, or with venial sin, it does not necessarily prevent the receiving of this sacrament, so as to make a man guilty of the body and blood of the Lord: but should it be with mortal sin, it prevents it of necessity.
For such illusions on the part of demons sometimes come from one's not striving to receive fervently; and this can be either a mortal or a venial sin. At other times it is due to malice alone on the part of the demons who wish to keep men from receiving this sacrament. So we read in the Conferences of the Fathers (Cassian, Collat. xxii) that when a certain one always suffered thus on those feast-days on which he had to receive Communion, his superiors, discovering that there was no fault on his part, ruled that he was not to refrain from communicating on that account, and the demoniacal illusion ceased.
In like fashion previous evil thoughts can sometimes be without any sin whatever, as when one has to think of such things on account of lecturing or debating; and if it be done without concupiscence and delectation, the thoughts will not be unclean but honest; and yet defilement can come of such thoughts, as is clear from the authority of Augustine (Objection [1]). At other times such thoughts come of concupiscence and delectation, and should there be consent, it will be a mortal sin: otherwise it will be a venial sin.
In the same way too the corporeal cause can be without sin, as when it arises from bodily debility, and hence some individuals suffer seminal loss without sin even in their wakeful hours; or it can come from the abundance of nature: for, just as blood can flow without sin, so also can the semen which is superfluity of the blood, according to the Philosopher (De Gener. Animal. i). But occasionally it is with sin, as when it is due to excess of food or drink. And this also can be either venial or mortal sin; although more frequently the sin is mortal in the case of evil thoughts on account of the proneness to consent, rather than in the case of consumption of food and drink. Hence Gregory, writing to Augustine, Bishop of the English (Regist. xi), says that one ought to refrain from Communion when this arises from evil thoughts, but not when it arises from excess of food or drink, especially if necessity call for Communion. So, then, one must judge from its cause whether such bodily defilement of necessity hinders the receiving of this sacrament.
At the same time a sense of decency forbids Communion on two accounts. The first of these is always verified, viz. the bodily defilement, with which, out of reverence for the sacrament, it is unbecoming to approach the altar (and hence those who wish to touch any sacred object, wash their hands): except perchance such uncleanness be perpetual or of long standing, such as leprosy or issue of blood, or anything else of the kind. The other reason is the mental distraction which follows after the aforesaid movements, especially when they take place with unclean imaginings. Now this obstacle, which arises from a sense of decency, can be set aside owing to any necessity, as Gregory says (Regist. xi): "As when perchance either a festival day calls for it, or necessity compels one to exercise the ministry because there is no other priest at hand."