<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>RE: [rt-users] Modify MIME::Entity Template Data from Scrip</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>
<P><FONT SIZE=2>just incase anyone else looks for the answer:<BR>
<BR>
$MIMEObj->bodyhandle(new MIME::Body::InCore $ticketcontent);<BR>
<BR>
will do it...<BR>
<BR>
Nicola<BR>
<BR>
-----Original Message-----<BR>
From: rt-users-bounces@lists.bestpractical.com on behalf of Foggi, Nicola<BR>
Sent: Fri 11/6/2009 1:00 PM<BR>
To: rt-users@lists.bestpractical.com<BR>
Subject: [rt-users] Modify MIME::Entity Template Data from Scrip<BR>
<BR>
<BR>
Hey Everyone,<BR>
<BR>
I'm working on a scrip that when an approval is approved and the parent ticket switches to "open" it emails a budget manager with the original pdf attachment of the quote, and the contents of the original request that went for approval.<BR>
<BR>
I've gotten the attachment working by using some code from the mailing lists to create the email via a scrip:<BR>
<BR>
$MIMEObj->make_multipart('mixed');<BR>
$MIMEObj->attach(<BR>
Type => $a->ContentType,<BR>
Charset => $a->OriginalEncoding,<BR>
Data => $a->OriginalContent,<BR>
Filename => $a->Filename,<BR>
Encoding => '-SUGGEST'<BR>
);<BR>
<BR>
i use load a template into the scrip and use it to send the email:<BR>
<BR>
my $template = RT::Template->new($RT::SystemUser);<BR>
$template->LoadQueueTemplate(Queue => $Queue->id, Name => $templatename);<BR>
<BR>
unless ( $template->Id ) {<BR>
$RT::Logger->crit(qq(Unable to load queue $Queue->id template $templatename));<BR>
die qq([ERROR] Unable to load queue $Queue->id template $templatename\n);<BR>
}<BR>
<BR>
... cropped ...<BR>
<BR>
if ( $RT::MailCommand eq 'sendmailpipe' ) {<BR>
eval {<BR>
open( MAIL, "|$RT::SendmailPath $RT::SendmailArguments" )<BR>
|| die $!;<BR>
print MAIL $MIMEObj->as_string;<BR>
close(MAIL);<BR>
};<BR>
if ($@) {<BR>
$RT::Logger->crit("Could Not Send Purchaser Email. -" . $@ );<BR>
die("[ERROR] Could Not Send Purchaser Email. -" . $@ );<BR>
}<BR>
}<BR>
else {<BR>
my @mailer_args = ($RT::MailCommand);<BR>
<BR>
local $ENV{MAILADDRESS};<BR>
<BR>
if ( $RT::MailCommand eq 'sendmail' ) {<BR>
push @mailer_args, split(/\s+/, $RT::SendmailArguments);<BR>
}<BR>
elsif ( $RT::MailCommand eq 'smtp' ) {<BR>
$ENV{MAILADDRESS} = $RT::SMTPFrom || $MIMEObj->head->get('From');<BR>
push @mailer_args, ( Server => $RT::SMTPServer );<BR>
push @mailer_args, ( Debug => $RT::SMTPDebug );<BR>
}<BR>
else {<BR>
push @mailer_args, $RT::MailParams;<BR>
}<BR>
<BR>
unless ( $MIMEObj->send(@mailer_args) ) {<BR>
$RT::Logger->crit("Could Not Send Purchaser Email." );<BR>
die "[ERROR] Could Not Send Purchaser Email.\n";<BR>
}<BR>
}<BR>
<BR>
<BR>
the problem i'm running into is i now can't get access to perl in the template, i'm guessing i'm missing something, so i thought well maybe I could use the MIMEObj in the scrip to access the body of the message and insert the "$Ticket->Transactions->First->Content()" but I can't figure out how to replace it. I used MIMEObj->bodyhandle( xxx ) but that didn't seem to do it.<BR>
<BR>
Any thoughts?<BR>
<BR>
Nicola<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>