Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Create and Pop Up Outlook Notes from Perl

by jdporter (Canon)
on Mar 03, 2003 at 21:03 UTC ( #240157=CUFP: print w/ replies, xml ) Need Help??

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.

Comment on Create and Pop Up Outlook Notes from Perl
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://240157]
Approved by Mr. Muskrat
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-09-21 16:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (172 votes), past polls