From Request Tracker Wiki
Revision as of 09:39, 14 June 2016 by Admin (talk | contribs)
Jump to navigation Jump to search

Original author: Michael Markstaller - IFCO

Code cleanups: RuslanZakirov

Require: Text::Wrapper perl module

 Subject: Resolved: {$Ticket->Subject}

 Dear customer,

 your issue regarding


 has been resolved in our ticket system. See below for history of this ticket.

 If you have any further questions or concerns, please reply to this
 message to reopen the ticket.


 {$Ticket->OwnerObj->RealName || $Ticket->OwnerObj->Name}

   Your initial request was


   Complete Ticket History

  my $resolved_message = '';
  my $last_content = '';

  my $transactions = $Ticket->Transactions;

  $transactions->Limit( FIELD => 'Type', VALUE => 'Correspond' );
  #If for some reason you want to expose internal comments to end users,
  #probably a bad idea, comment out the previous line & uncomment these:
  #$transactions->Limit( FIELD => 'Type', VALUE => 'Correspond', ENTRYAGGREGATOR => 'OR', OPERATOR => '=' );
  #$transactions->Limit( FIELD => 'Type', VALUE => 'Comment', ENTRYAGGREGATOR => 'OR', OPERATOR => '=' );

  while (my $transaction = $transactions->Next) {
    my $attachments = $transaction->Attachments;

    while (my $message = $attachments->Next) {
      next unless $message->ContentType =~

      my $content = $message->Content;
      $content =~ s/<(([^ >]|\n)*)>//g;  # strip HTML tags from text/html
      next unless $content;

      next if $last_content eq $content;
      $last_content = $content;

      my $subject = ($message->Subject || $Ticket->Subject);

      my $wrapper = Text::Wrapper->new(columns=>70);
      $content = $wrapper->wrap($content);

      $resolved_message .= "Subject: ";
      $resolved_message .= $subject;
      $resolved_message .= "\n";
      $resolved_message .= "From: ";
      $resolved_message .= $message->CreatorObj->RealName || $message->CreatorObj->EmailAddress;
      $resolved_message .= "\n";
      $resolved_message .= "Time: ";
      $resolved_message .= $message->CreatedObj->AsString;
      $resolved_message .= "\n";
      $resolved_message .= "\n";
      $resolved_message .= "$content\n";
      $resolved_message .= "------------------------------------------------\n";

    Common Information

 There is no need to reply to this message unless you want to RE-OPEN your
 ticket with ID [{$rtname} #{$Ticket->id}].

 If you want to simply add a COMMENT to this ticket without re-opening the ticket, click below:[{$rtname}%20#{$Ticket->id()}]&body=%20

 Please note:
 - ALWAYS include the string [{$rtname} #{$Ticket->id}] in the subject line of all future correspondence about this issue.
 - Do NOT attach or include the content of previous emails already sent to you by rt.