ForwardWithMessage: Difference between revisions
Jump to navigation
Jump to search
m (3 revisions imported) |
m (better formating of the code) |
||
Line 17: | Line 17: | ||
: Create /local/lib/RT/Interface/Email_Local.pm and add following content. (Differences to Email.pm are bold) | : Create /local/lib/RT/Interface/Email_Local.pm and add following content. (Differences to Email.pm are bold) | ||
<source lang=perl> | |||
use strict; | use strict; | ||
'''no warnings qw(redefine);''' | '''no warnings qw(redefine);''' | ||
Line 125: | Line 127: | ||
1; | 1; | ||
</source> | |||
That's it. Hopefully it helps someone. | That's it. Hopefully it helps someone. |
Latest revision as of 10:42, 6 February 2025
You can't forward a ticket or transaction with a message for the recipient. To change that:
- Insert a textarea for the message on Forward-Page:
- Copy /html/Ticket/Forward.html to /local/html/Ticket/Forward.html
- Open /local/html/Ticket/Forward.html and insert after
<input name="Bcc" size="60" value="<% $ARGS{'Bcc'} || '' %>" />
- a new table-row with a textarea for the message:
<&|/l&>Message</&>:
<textarea name="Message" cols="51"><% $ARGS{'Message'} || '' %></textarea>
- Send message per Mail and store it in the Forward-Transaction:
- Create /local/lib/RT/Interface/Email_Local.pm and add following content. (Differences to Email.pm are bold)
use strict;
'''no warnings qw(redefine);'''
package RT::Interface::Email;
use Email::Address;
use MIME::Entity;
use RT::EmailParser;
use File::Temp;
use UNIVERSAL::require;
use Mail::Mailer ();
use Text::ParseWords qw/shellwords/;
sub ForwardTransaction {
my $txn = shift;
my %args = ( To => '', Cc => '', Bcc => ''''', Message => ''''', @_ );
'''my $entity = MIME::Entity->build('''
''' Type => 'multipart/mixed','''
''' Description => 'forwarded transaction','''
''' );'''
''' my $mimeMessage = MIME::Entity->build('''
''' Type => 'text/plain; charset="utf-8"','''
''' Data => $args{Message}'''
''' );'''
''' $entity->add_part($mimeMessage);'''
''' $entity->add_part($txn->ContentAsMIME);'''
my ( $ret, $msg ) = SendForward( %args, Entity => $entity, Transaction => $txn );
if ($ret) {
my $ticket = $txn->TicketObj;
'''my ( $ret, $msg, $createdTrans ) = $ticket->_NewTransaction('''
Type => 'Forward Transaction',
Field => $txn->id,
Data => join ', ', grep { length } $args{To}, $args{Cc}, $args{Bcc},
);
''' #Attach message for Recipients to Transaction'''
''' $createdTrans->_Attach('''
''' MIME::Entity->build('''
''' Type => 'text/plain','''
''' Data => $args{Message})'''
''' );'''
unless ($ret) {
$RT::Logger->error("Failed to create transaction: $msg");
}
}
return ( $ret, $msg );
}
sub ForwardTicket {
my $ticket = shift;
my %args = ( To => '', Cc => '', Bcc => ''''', Message=>''''', @_ );
my $txns = $ticket->Transactions;
$txns->Limit(
FIELD => 'Type',
VALUE => $_,
) for qw(Create Correspond);
my $entity = MIME::Entity->build(
Type => 'multipart/mixed',
Description => 'forwarded ticket',
);
''' my $mimeMessage = MIME::Entity->build('''
''' Type => 'text/plain; charset="utf-8"','''
''' Data => $args{Message}'''
''' );'''
''' $entity->add_part($mimeMessage);'''
$entity->add_part( $_ ) foreach
map $_->ContentAsMIME,
@{ $txns->ItemsArrayRef };
my ( $ret, $msg ) = SendForward(
%args,
Entity => $entity,
Ticket => $ticket,
Template => 'Forward Ticket',
);
if ($ret) {
''' my ( $ret, $msg, $createdTrans ) = $ticket->_NewTransaction('''
Type => 'Forward Ticket',
Field => $ticket->id,
Data => join ', ', grep { length } $args{To}, $args{Cc}, $args{Bcc}
);
''' #Attach message for Recipients to Transaction'''
''' $createdTrans->_Attach($mimeMessage);'''
unless ($ret) {
$RT::Logger->error("Failed to create transaction: $msg");
}
}
return ( $ret, $msg );
}
1;
That's it. Hopefully it helps someone.