#!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 settable):
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;