[rt-devel] HELP--Cant get attachments into scrip Templates...
Arthur de Jong
arthur at West.NL
Mon Nov 19 03:35:38 EST 2001
On Thu, 15 Nov 2001, Joshua Johnson wrote:
> All,
> Sorry if this is just too obvious but I cannot seem to make it work. I
> wish to send the correspondence text as well as the attachment in a
> template. For me {$Transaction->Content()} does not send the
> attachment. ( I don't think it should, by definition it only sends
> the first /text-plain part if I am reading it correclty ) but what
> other Sequence do I need to do to get the attachments sent ? Am I even
> close with {$Transaction->Message()->First()->print();} ? Is there a
> loop I need to run?
We use this template for our correspondence. It's not great but it's a
start.
--------8<--------
Subject: {$Transaction->Subject || "Re: [".$rtname." #".$Ticket->id."] (".$Ticket->QueueObj->Name.") ".$Ticket->Subject}
{$Transaction->Content()}
{
my $attachments = $Transaction->Attachments;
$attachments->GotoFirstItem;
my $c=0;
$attachments->Next;
my $out;
while (my $attachment=$attachments->Next) {
next unless ($attachment->Content || $attachment->Children->Count);
$c++;
next if $c<2;
$out.=sprintf("\n-- attachment %2d ------------------------------------------------------\n",$c-1);
if ($attachment->ContentType =~ m{^(text/plain|message|text$)}i && length($attachment->Content)<4096) {
$out.=$attachment->Content;
} else {
$out.="url: ".$RT::WebURL."Ticket/Attachment/".$Transaction->Id."/".$attachment->Id."/".$attachment->Filename."\n";
}
}
$out;
}
-- request information ------------------------------------------------
request: [{$rtname} #{$Ticket->id}] ({$Ticket->QueueObj->Name})
{$Ticket->Subject}
status: {$Ticket->Status}
owner: {$Ticket->OwnerObj->Name}
url: {$RT::WebURL}Ticket/Display.html?id={$Ticket->id}
--------8<--------
Note that there might be some newlines in there that you should take out.
I have not yet found out a way to construct messages with attachments with
the templates.
-- arthur de jong - arthur at west.nl - west consulting b.v. --
More information about the Rt-devel
mailing list