The indolizidone 9, the pyrrolizidone 14, a mixture of heliotridone 15a and pseudoheliotridone 15b and the lactam 19 have been synthesized in a one-step anthraquinone-photocatalysed reaction of the corresponding amines, piperidine 1, pyrrolidine 10 and morpholine 16, with alpha,beta-unsaturated esters.