Created
July 10, 2012 14:52
-
-
Save anonymous/3083791 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] . " " . $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