chanakya has asked for the wisdom of the Perl Monks concerning the following question:
Running the above script results in a /tmp file with the following results:#!/usr/local/bin/perl -w use MIME::Parser; use File::Basename; use strict; # derive the base filenames of extracted parts from # the name of the script. my ($parsed) = (basename($0))[0]; #Create a Parser object my $parser = MIME::Parser->new(); # output directory for parsed files $parser->output_dir("/tmp"); # Basenames for parsed files $parser->output_prefix($parsed); $parser->output_to_core(); open(INPUT, "/tmp/email-test/AuthenticationReport.msg") or die("Input +error: $!"); my $entity = $parser->read(\*INPUT) or die "couldn't parse MIME stream"; close(INPUT); # Tell us about the MIME entities! this is for debugging $entity->dump_skeleton;
Moving on, I want to parse the three attachments and the data within them and insert the data into the database (Oracle).------=_Part_64_24417480.1094663686411 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: BASE64 ------=_Part_64_24417480.1094663686411 Content-Type: application/octet-stream; name=User_Logins_UnitDaily_Test_User_09_08_2004_10_14_45_DAY20 +04-9-8_18.mhtml Content-Transfer-Encoding: BASE64 Content-Disposition: attachment; filename=User_Logins_UnitDaily_Test_User_09_08_2004_10_14_45_D +AY2004-9-8_18.mhtml ------=_Part_64_24417480.1094663686411 Content-Type: application/octet-stream; name=Admin_Logins_UnitDaily_Test_User_09_08_2004_10_14_45_DAY2 +004-9-8_18.mhtml Content-Transfer-Encoding: BASE64 Content-Disposition: attachment; filename=Admin_Logins_UnitDaily_Test_User_09_08_2004_10_14_45_ +DAY2004-9-8_18.mhtml ------=_Part_64_24417480.1094663686411 Content-Type: application/octet-stream; name=Disabled_Logins_UnitDaily_Test_User_09_08_2004_10_14_45_D +AY2004-9-8_18.mhtml Content-Transfer-Encoding: BASE64 Content-Disposition: attachment; filename=Disabled_Logins_UnitDaily_Test_User_09_08_2004_10_14_ +45_DAY2004-9-8_18.mhtml ------=_Part_64_24417480.1094663686411--
IF there is not activity then the attachment displays "No Data" instead of "Time" and "Address".Cisco Reports ------------- Scheduled report for Cisco at IP address 18.187.12.10(Test1 - 0002321) ------------------------------------------------------------------- Disabled Logins for 2004-10-02 Time Address 10.10.58 18.188.10.12 10.12.34 17.199.13.100
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing mhtml attachment reports
by Util (Priest) on Jan 02, 2005 at 20:45 UTC | |
by chanakya (Friar) on Jan 03, 2005 at 06:12 UTC | |
|
Re: Parsing mhtml attachment reports
by Fletch (Bishop) on Jan 02, 2005 at 20:30 UTC | |
|
Re: Parsing mhtml attachment reports
by Aristotle (Chancellor) on Jan 02, 2005 at 22:49 UTC |