Add all comments to mail

Hi all,
How to include the text of the all comments of ticket in an email template?
Thanks

In a Perl based template $Ticket is the ticket object, so you can use that to get all the transactions on the ticket and then limit them to the type you want and iterate through them to find content to add to the email.

Maybe something like this:

{
    our $email = 'Subject: All comments on ' . $Ticket->id . "\nContent:\n\n";
    my $transactions = $Ticket->Transactions();
    $transactions->Limit(FIELD => 'Type', Value => 'Comment');
    while(my $thisTxn = $transactions->Next) {
        if($thisTxn->HasContent() ) {
            $email .= "Comment Transaction #" . $thisTxn->id . ":\n".
               $thisTxn->Content . "\n\n";
        }
    }
    $email;
}