anonymous / gist:3083791
Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View gist:3083791
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
use warnings;
use strict;
 
use Mail::POP3Client;
use MIME::Base64;
 
my $hostname = "xxxxxx";
my $username = "xxxxx;
my $password = "xxxxx";
 
my $conn = new Mail::POP3Client( USER => $username, PASSWORD => $password, HOST => $hostname );
 
my $email_number = $conn -> Count() - 11; #get the latest email # from Count();
 
print "\n\n<!DOCTYPE html>\n";
print "<html>\n";
print "<body>\n";
print "<p>\n";
 
foreach( $conn->Head( $email_number ) ) {
/^(From|Subject):\s+/i && print $_, "\n";
}
 
print "</p>\n\n";
 
my $ciphertext = $conn->Body( $email_number );
 
#clean the ciphertext
$ciphertext =~ s/Content-Type:\stext\/plain;//g;
$ciphertext =~ s/charset="utf-8"//g;
$ciphertext =~ s/Content-Transfer-Encoding:\sbase64//g;
$ciphertext =~ s/Content-Type:\stext\/html;//g;
$ciphertext =~ s/--_000_41DADE848657754488503BD616F1ADE607250A88_--//g;
$ciphertext =~ s/--_000_41DADE848657754488503BD616F1ADE607317EE6_//g;
$ciphertext =~ s/--_000_41DADE848657754488503BD616F1ADE6073C5F3B//g;
 
my $plaintext = decode_base64( $ciphertext );
#print "Body: " . $plaintext;
 
my @plain = split(/\n/,$plaintext);
 
#@plain = grep { defined() and length() } @plain; # this eliminates the blank elements in the array, but its not a good idea if one of the column is blank
=pod
foreach(@plain){
if( ( defined $_) and !($_ =~ /^$/ )){
push(@plain, $_);
}
}
=cut
 
my $plain = @plain;
 
print "arraysize: " . $plain;
 
my $note_num = 1;
 
my $i = 38;
my $j = 0;
my $x = 0;
 
while (!($plain[$i] =~ /Grand/)){
print "\n\n<br><h3>NOTE # $note_num</h3>\n";
$note_num++;
 
print "<p>Case Owner: " . $plain[$i] . "</p>\n";
$i = $i + 2;
print "<p>Created By: " . $plain[$i] . "</p>\n";
$i = $i + 2;
print "<p>GoToAssist ID: " . $plain[$i] . "</p>\n";
$i = $i + 2;
 
$x = $i;
$j = $i+2;
# $plain[$x] = "";
#scan the elements until you find 'Email' or 'Phone' or 'GoToAssist'
while(!($plain[$j] =~ /[Email|Phone|GoToAssist]/)){
# if(defined $plain[$j]){
$plain[$x] = $plain[$x] . "&nbsp;" . $plain[$j];
$j++;
# }
}
 
print "<p>Description: " . $plain[$x] . "</p>\n";
$i = $j;
print "<p>Case Origin: " . $plain[$i] . "</p>\n";
$i = $i + 2;
$x = $i;
$j = $i+2;
# $plain[$x] = "";
while(!($plain[$j] =~ /\d\.\d/)){ #scan the lines until you find "digit.digit"
# if(defined $plain[$j]){
$plain[$x] .= " " . $plain[$j];
$j++;
# }
}
 
print "<p>Resolution Summary: " . $plain[$x] . "</p>\n";
$i = $j;
#print "<p>Case Comments: " . $plain[$i] . "</p>\n";
#$i = $i + 2;
print "<p>Version Reported: " . $plain[$i] . "</p>\n";
$i = $i + 2;
print "<p>Product Feature: " . $plain[$i] . "</p>\n";
$i = $i + 2;
print "<p>Product: " . $plain[$i] . "</p>\n";
$i = $i + 2;
print "<p>Contact Name: " . $plain[$i] . "</p>\n";
$i = $i + 2;
print "<p>Affected Owner: " . $plain[$i] . "</p>\n";
$i = $i + 2;
print "<p>Case ID: " . $plain[$i] . "</p>\n";
$i = $i + 2;
print "<p>Case Number: " . $plain[$i] . "</p>\n";
$i = $i + 2;
print "<p>Account Name: " . $plain[$i] . "</p>\n";
$i = $i + 2;
print "<p>Subject: " . $plain[$i] . "</p>\n";
$i = $i + 2;
print "<p>Date/Time Opened: " . $plain[$i] . "</p>\n";
$i = $i + 2;
print "<p>Closed: " . $plain[$i] . "</p>\n";
$i = $i + 2;
}
 
print "</body>\n";
print "</html>";
 
=pod
for(my $i = 0; $i < $plain; $i++){
print "\n" . $i . " <> " . $plain[$i];
}
=cut
 
$conn->close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.