When you commit a mortal sin, the only way to be returned to grace prior confession is to have perfect contrition.
This is taken from St. Louis de Montfort, and paraphrased and expanded from other sources.
Think of Jesus hanging on the cross. Struggling to breath. Everyone around Him mocking Him. Covered in blood and in agonizing pain. Submerged in mental anguish and humiliation. Know that you have done this to Him, your God, your greatest benefactor. The One who gave you life and keeps you alive. The one who prepared a place for you in eternal bliss. Instead of loving and thanking Him, you crucified and insulted Him. This should move you to perfect contrition for your sins. Now say a heartfelt Act of Contrition, meaning every word. Resolve to go to confession as soon as possible. You will be restored to God’s Grace, and all eternal punishment of your sin will be removed. You must go to confession first before Communion though.
Please spread the word about perfect contrition!