ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-users
perl-win32-users
RE: Outlook, Perl & OLE
by Charbeneau, Chuck other posts by this author
Nov 6 2002 12:59PM messages near this date
view in the new Beta List Site
locales reference? | RE: TK - stop dos window minimising?
>  From: Harald Wopenka [mailto:hwopenka@[...].at] 
>  Subject: Outlook, Perl & OLE
>  
>  
>  Hi there,
>  does anybody know a good source of examples and/or 
>  descriptions how to manipulate MS Outlook? I want to access 
>  my contacts (read, create, delete) and calendarentries... tia Harry


Well, I can get you started with Contacts, and you should be able to take it
from there to your calendar.  If you have problems beyond that, ask.

<CODE> 
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Outlook';
$|++;
$Win32::OLE::Warn = 3; # Throw Errors, I'll catch them

my $OL = Win32::OLE-> GetActiveObject('Outlook.Application')
	    || Win32::OLE-> new('Outlook.Application', 'Quit');

    my $NameSpace = $OL-> GetNameSpace("MAPI");
    my $Contacts =  $NameSpace-> Folders("Personal
Folders")-> Folders("Contacts");#GetDefaultFolder(olFolderContacts);
    
    my @names = qw(Chuck Charles Charlie Chuckles);
    foreach my $name (@names){
        my $NewContact = $Contacts-> Items->Add();#($NewContact); 
           $NewContact-> {FirstName}=$name;
           $NewContact-> {LastName}="Charbeneau";
           $NewContact-> Save();
           print "Added $name\n";
    }
    
    $Contacts =  $NameSpace-> Folders("Personal
Folders")-> Folders("Contacts")->{Items};#GetDefaultFolder(olFolderContacts);
    my $Cacharbes = $Contacts-> Find("[LastName]=Charbeneau");
    my $cnt = 0;
    while (1) {
      print $Cacharbes-> {FirstName}." : ".$Cacharbes->{EntryID}."\n";
      if ($Cacharbes-> {FirstName} eq "Chuckles"){
          
          $Cacharbes-> Delete();
      }
      $Cacharbes = $Contacts-> FindNext() || last;     
   }

</CODE> 

Chuck.
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved