Calculation of correlation energy by many-body diagrammatic perturbation theory