Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
use strict; use Win32::OLE qw(in); use HTML::Template; { package Wrapper::Notes::Template; use strict; use File::Spec; sub new { my ($class,$document, $attachmentdir) = @_; my $self = { document => $document, attachments => $attachmentdir +}; bless $self, $class; $self; }; sub document { $_[0]->{document} }; sub param { my ($self,@args) = @_; if (scalar @args) { my $result; if ($_[1] eq 'Attachments') { my $result = []; my $body = $self->document->GetFirstItem('Body'); my @attachments = grep { warn join ":",$_->{Name}, $_->{Type}, +$_->{Text}; $_->{Type} == 4 } (@{$self->document->Items()}); mkdir $self->{attachments}; for my $attname (@attachments) { my $url = File::Spec->catfile($self->{attachments},$attname) +; $url = File::Spec->rel2abs($url); #warn "Extracting $attname to $url"; my $f = $self->document->getAttachment($attname); if ($f) { $f->extractFile($url); push @$result, { name => $attname, url => $url }; }; }; return $result; } elsif ($_[1] eq 'EmbeddedObjects') { my $result = []; my $body = $self->document->GetFirstItem('Body'); my $attachments = $body->EmbeddedObjects; if ($attachments) { mkdir $self->{attachments}; for my $att (Win32::OLE::in $attachments) { warn $att->{Type}; my $url = File::Spec->catfile($self->{attachments},$att- +>{Name}); $url = File::Spec->rel2abs($url); $att->extractFile($url); push @$result, { name => $att->{Name}, url => $url }; }; }; return $result; } else { $result = $self->document->{$_[1]}; }; if (ref $result) { return [ map { "value" => $_ }, @$result ]; } else { $result; }; } else { return (map { $_->Name } (Win32::OLE::in ($self->document->Items +()))), "Attachments", "EmbeddedObjects"; }; }; }; my ($server,$database) = ('server','mail/corion.nsf'); my $Notes = Win32::OLE->new('Notes.NotesSession') or die "Cannot start Lotus Notes Session object.\n"; my ($Version) = ($Notes->{NotesVersion} =~ /\s*(.*\S)\s*$/); print "The current user is $Notes->{UserName}.\n"; print "Running Notes \"$Version\" on \"$Notes->{Platform}\".\n"; my $Database = $Notes->GetDatabase($server, $database); my $AllDocuments = $Database->AllDocuments; my $Count = $AllDocuments->Count; print "There are $Count documents in the database.\n"; my $Index = 4419; while (++$Index <= $Count) { my $Document = $AllDocuments->GetNthDocument($Index); my $wrapper = Wrapper::Notes::Template->new($Document,sprintf "ema +il/mail.%05g",$Index); my $template = HTML::Template->new( filename => 'lotus-email.tmpl', die_on_bad_params => 0, loop_context_vars => 1, associate => [ $wrapper ], case_sensitive => 1, ); my $outfile = sprintf "email/mail.%05g.html", $Index; open MAIL, ">", $outfile or die "Couldn't create '$outfile' : $!\n +"; $template->output( print_to => *MAIL ); close MAIL; last unless $Index <= 4420; # magic number! }

In reply to Extract Lotus Notes Mail to HTML by Corion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2022-08-14 02:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?