Convolution of cuspforms with theta series and the generalized Voronoi formula