For you Microsoft Outlook users, here are two little command-line utilities that let you create and pop up Outlook Notes. They are pretty simple, but may serve as examples of how to use Win32::OLE productively with Outlook Notes (as opposed to Lotus Notes ;-)
#!perl
use warnings; use strict;
use Win32::OLE; use Win32::OLE::Const 'Microsoft Outlook';
use Getopt::Long;
=pod
This reads the note contents from <>, so you can type into it
or pipe into it from another program, for example.
The Subject is calculated from the Body - specifically, it is taken
from the first line of the Body, at the time the Save operation is
performed.
A NoteItem contains the following properties (not all of which are set
+table):
Application
Class
Session
Parent
Body
Categories
Color
CreationTime
EntryID
GetInspector
Height
LastModificationTime
Left
MessageClass
Saved
Size
Subject
Top
Width
Links
DownloadState
ItemProperties
MarkForDownload
IsConflict
Colors are enumerated as follows:
0 Blue
1 Green
2 Pink
3 Yellow
4 White
=cut
my @colors = qw( blue green pink yellow white );
my %colors;
@colors{@colors} = (0 .. $#colors);
my $color;
GetOptions( 'color=s' => \$color );
my $ol = Win32::OLE->new('Outlook.Application') or die
"Unable to create an Outlook context: $!\n";
my $noteitem = $ol->CreateItem( olNoteItem ) or die
"Unable to create a new Note: $!\n";
undef $/;
$noteitem->{'Body'} = <>; # sluurp
if ( defined $color )
{
my $i = $colors{lc $color};
defined $i and
$noteitem->{'Color'} = $i;
}
$noteitem->Save;
#!perl
use warnings; use strict;
use Win32::OLE; use Win32::OLE::Const 'Microsoft Outlook';
=pod
This takes the value of a note Subject from the command line arguments
+,
looks for a note with that identification, and displays it.
If no note is found with the given Subject, an OLE error results.
=head1 TO DO
Allow searching for notes in subfolders.
E.g. Given note name "Archive/How To", we will search
in subfolder "Archive" for a note named "How To".
=cut
Win32::OLE
->new('Outlook.Application')
->session
->GetDefaultFolder( olFolderNotes )
->Items( "@ARGV" )
->Display;
jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.