Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
laziness, impatience, and hubris
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I have made some changes to help Palm III owners. The Palm III has a size limit on Memo files of 4 Kb. The following code will chop up large files into chunks of 4 Kb and create a separate Outlook note for each chunk, giving each a part number:


#!/usr/bin/perl -w # Takes the text file(s) specified on the command line and puts them # into Outlook notes. If you have a Palm pilot and use Chapura's # PocketMirror, then Outlook notes get copied into Palm memos when # you synchronise. use strict; use diagnostics; use Win32::OLE; use Win32::OLE::Const; my $Outlook = get_outlook_handle(); # Outlook OLE constants my $olc = Win32::OLE::Const->Load($Outlook); # We have to expand all wild-cards, because the Windows command shell # doesn't. We only want plain, text files, and we want to read them # whole, not a line at a time. @ARGV = map { glob } @ARGV; @ARGV = grep { -f && -T } @ARGV; undef $/; while (<>) { # Code to chop up input files into 4000 byte blocks. Required # because of the Palm III's 4 Kb memo limit. if (length >= 4000) { my $counter = 1; my @part = /.{1,4000}/gs; foreach (@part) { my $title = "$ARGV part $counter"; create_outlook_note($title, $_); $counter++; } } else { create_outlook_note($ARGV, $_); } } sub get_outlook_handle { my $Outlook; # Make sure we are on windows die "This script is only good for Windows." unless ($^O eq "MSWin32" +); # Make sure we have Outlook, and that it is running. Chicken out if # either of these is not the case. eval {$Outlook = Win32::OLE->GetActiveObject('Outlook.Application')} +; die "Outlook not installed." if $@; die "Outlook needs to be running." unless defined $Outlook; return $Outlook; } # Create an Outlook note, putting the title on the first line of the # note sub create_outlook_note { my ($title, $body) = @_; # New note my $note = $Outlook->CreateItem($olc->{olNoteItem}); $note->{Body} = "$title\n$body"; # Optional note properties. $note->{Categories} = "Business"; $note->{Width} = 800; $note->{Height} = 600; $note->{Top} = 20; $note->{Left} = 20; # Close and save note. $note->close($olc->{olSave}); }



Also, using the following Emacs lisp code in the _emacs file will call the program making sure the current buffer file name is put in the first line of the Outlook note:

;; Make F9 key copy the entire buffer to a new MS Outlook note (global-set-key [f9] ' copy-buffer-to-outlook-note) ; Copy entire buffer to MS Outlook note (defun copy-buffer-to-outlook-note () "Copy current buffer to MS Outlook note." (interactive) (shell-command (format "%s %s" "perl c:/perl/txt2note.pl" buffer-fi +le-name)))

In reply to Re: Outlook/Palm/PocketMirror users, take note... by perlmoth
in thread Outlook/Palm/PocketMirror users, take note... by Anonymous Monk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (6)
    As of 2014-04-21 11:22 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (493 votes), past polls