Oops.. Did a little more looking. Appears that the order is already saved to the database at the point that the email is generated, so instead of

Code:
$orderhistory->RecordCount() == 0
it should be:

Code:
$orderhistory->RecordCount() == 1
To provide the new order message for the first order...