the two distinct were missing!

the two "distinct" were missing leading to wrong attachment count value and duplicate entries of cc_emails