This block seems to be redundant - we're running on hook_mail and therefore we should always be recording the note to connection.transaction.notes and not to connection.notes.