In this paper we consider the integral functionals of the general epidemic model up to its extinction. We develop a new approach to determine the exact Laplace transform of such integrals. In particular, we obtain the Laplace transform of the duration of the epidemic T, the final susceptible size ST, the area under the trajectory of the infectives AT, and the area under the trajectory of the susceptibles BT. The method relies on the construction of a family of martingales and allows us to solve simple recursive relations for the involved parameters. The Laplace transforms are then expanded in terms of a special class of polynomials. The analysis is generalized in part to Markovian epidemic processes with arbitrary state-dependent rates.