Obtaining the first Attachment in a scrip

I use DSPAM to catch SPAM coming through my e-mail server. DSPAM
"learns" what SPAM looks like by example – you tell it what is SPAM and
what is HAM. DSPAM tags each email with an ID that lets it reverse
entries. Any time you receive an email that has been misclassified you
can send it back to DSPAM and it will learn from its mistakes.

That said, I get email to some of my RT queues that are SPAM. DSPAM has
them classified as good, and I want an easy way for my users to be able
to ship them back for reclassification. The way I thought about doing
that was by making a simple “SPAM” queue, then instructing my users to
simply altering the queue of a misclassified messages to Spam. In the
scrips section of my Spam queue I want to use “On Queue Change” to
notify the AdminCC (which is a bogus user with an email adress that will
route back to DSPAM). My problem is that I need the original
attachment, so $Transaction->Content will not fit the bill. To do that,
I need the first attachment.

I created a template called FirstAttachment that contains only the
following code:


which from my Googling and searching through the mailing list would seem
to return what I want. Instead of an email being sent, nothing is. If
I choose a different template then the expected email gets sent.

Is the code I listed above what I’m looking for? e.g. Should this
return the first attachment (the original email) of my ticket?

Thanks in advance for your assistance.


I know it’s bad form to reply to yourself, but I stole some code from

changing it to the template:

RT-Attach-Message: yes

my $resolution_comment;
my $Transactions = $Ticket->Transactions;

$Transactions->Limit( FIELD => ‘Type’, VALUE => ‘Create’ );

my $CommentObj = $Transactions->First;
if( $CommentObj && $CommentObj->id ) {
$resolution_comment = $CommentObj->Content;


and that (pardon the pun) was the ticket…

Further investigation on the wiki give me what may be an even easier

{ $Ticket->Transactions->First->Content; }

I didn’t try it, though.