[rt-users] How to get file from custom field to resolve message PLEASE HELP!
Joe Casadonte
joe.casadonte at oracle.com
Wed Mar 14 12:54:24 EDT 2007
On 3/14/2007 4:31 AM, Loos, Christian wrote:
> Hello,
>
> me and my colleague ask questions to this point three times but no responses.
> But the must be someone out there done this befor. So please help us!
>
> We have an ticket custom field from type upload one file.
> If we resolve an ticket this file should be send with the resolve mail.
> I figured out how to get the link to this file.
> But i don't know how to get this file as an attachment to the resolve mail.
I have no clue how to do this in a template, but if you have coded up
the action yourself to send the email, you would have a MIMEObj (which
is a MIME:Entity, I think). With that, it should be simple to attach
the file via 'attach'. You may need to get the file out of RT first,
though; I have no clue how to do that.
Example of sending an email is included here, but without the attach. I
got this from somewhere else, not sure where (maybe RT Essentials):
my $template = RT::Template->new($RT::SystemUser);
$template->LoadGlobalTemplate('MY_NewAccountCreated');
unless ( $template->Id ) {
$RT::Logger->crit(qq(Unable to load template
"MY_NewAccountCreated"));
die qq([ERROR] Unable to load template "MY_NewAccountCreated"\n);
}
my($result, $message) = $template->Parse(Argument => {UID =>
$username, PWD => $password});
if (! $result) {
$RT::Logger->warning("Template object failed to parse - $message");
die("[ERROR] Template object failed to parse - $message\n");
}
my $MIMEObj = $template->MIMEObj;
$MIMEObj->head->set('To', $user->EmailAddress);
$MIMEObj->head->set('From', $RT::CorrespondAddress);
if ( $RT::MailCommand eq 'sendmailpipe' ) {
eval {
open( MAIL, "|$RT::SendmailPath $RT::SendmailArguments" )
|| die $!;
print MAIL $MIMEObj->as_string;
close(MAIL);
};
if ($@) {
$RT::Logger->crit("Could not welcome message. -" . $@ );
die("[ERROR] Could not welcome message. -" . $@ );
}
}
else {
my @mailer_args = ($RT::MailCommand);
local $ENV{MAILADDRESS};
if ( $RT::MailCommand eq 'sendmail' ) {
push @mailer_args, split(/\s+/, $RT::SendmailArguments);
}
elsif ( $RT::MailCommand eq 'smtp' ) {
$ENV{MAILADDRESS} = $RT::SMTPFrom ||
$MIMEObj->head->get('From');
push @mailer_args, ( Server => $RT::SMTPServer );
push @mailer_args, ( Debug => $RT::SMTPDebug );
}
else {
push @mailer_args, $RT::MailParams;
}
unless ( $MIMEObj->send(@mailer_args) ) {
$RT::Logger->crit("Could not send welcome message." );
die "[ERROR] Could not send welcome message.\n";
}
}
--
Regards,
joe
Joe Casadonte
joe.casadonte at oracle.com
========== ==========
== The statements and opinions expressed here are my own and do not ==
== necessarily represent those of Oracle Corporation. ==
========== ==========
More information about the rt-users
mailing list