added end notificitaion code

This is a static utility function. We can move it to some util class later. Added a log just before send mail call that prints the query id.