Global Script - Using Mail Events
The Mail object provides 2 events, called at the beginning and at the end of each email rendering. This means the events are called once per each receiver.
Check the Server Side Scripting Guide to see how you can use these events.
Object Event Description
Mail OnStartRender Called when rendering starts for current receiver.
Mail OnEndRender Called when rendering ends for current receiver.