Skip to content

Instantly share code, notes, and snippets.

@jkeroes
Created July 3, 2013 23:16
Show Gist options
  • Select an option

  • Save jkeroes/5923686 to your computer and use it in GitHub Desktop.

Select an option

Save jkeroes/5923686 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use 5.10.0;
use Email::Folder::Exchange::EWS;
use Email::MIME;
use Try::Tiny;
use YAML::XS;
my $uri = 'https://secure.integratelecom.com/ews/exchange.asmx';
my $user = 'INTEGRA\jkeroes';
my $pass = 'redacted';
my $VERBOSE = 1;
my $folder = Email::Folder::Exchange::EWS->new($uri, $user, $pass);
for my $message ($folder->messages) {
my $to = $message->header('To');
my $from = $message->header('From');
my $subj = $message->header('Subject');
my $mid = $message->header('Message-ID') or die "Can't find message id";
say "to: $to" if $VERBOSE;
say "from: $from" if $VERBOSE;
say "subject: $subj" if $VERBOSE;
my $parsed = Email::MIME->new($message->body);
my $body = $parsed->body;
say "body: $body" if $VERBOSE >= 2;
my $is_num_subj = $subj =~ /^ICC Task: NETWORK UTILIZATION MONITORING/;
my $is_num_to = $to =~ /cricket/i;
if ($is_num_to && is_num_subj && $VERBOSE) {
say "Found ICC cricket order";
(my $cust = $body) =~ /^SUBSCRIBER: \d+ \(.*?\)\s*$/m;
say "cust: $cust" if $VERBOSE;
# $DB::single++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment