in reply to Re: Check your property Names in the Outlook ContactItem Class
in thread Perl control of Outlook import to contacts with win32::OLE

Oh wise C, I wish to thank you for this help. You have given me the tools to finish a very important project. Thanks again.
  • Comment on Re: Re: Check your property Names in the Outlook ContactItem Class

Replies are listed 'Best First'.
Re: Re: Re: Check your property Names in the Outlook ContactItem Class
by cacharbe (Curate) on May 24, 2002 at 15:32 UTC
    Null Perspiration.

    cacharbe's the name, Win32:OLE is my game.

    C-.

      C, Here I am bothering you again. I have had much success thanks to your instruction. I have been very successful in finding and deleting items from contacts folder. Here is my question: I have the following snipet:
      my $NewContact = $Contacts->Items->find("[Last Name] = $name"); print "full name: $NewContact->{FullName}\n"; print "First name: $NewContact->{FirstName}\n"; print "Last name: $NewContact->{LastName}\n"; print "Phone: $NewContact->{BusinessTelephoneNumber}\n"; print "Title: $NewContact->{CompanyName}\n"; $NewContact->Delete();
      Now there may be a bunch of Smiths and I don't want to trash all of them - How can I do this same thing by index. The whole index deal leaves me a little lost - how do I return and index to script? Thanks
        I would look at the parameters on which you DO want to delete, and work it something like this. (Based on the following)
        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");

        I used this to fill in some values:

        my $Contacts = $NameSpace->Folders("Personal Folders")->Folders("Cont +acts"); my @names = qw(Chuck Charles Charlie Chuckles); foreach my $name (@names){ my $NewContact = $Contacts->Items->Add(); $NewContact->{FirstName}=$name; $NewContact->{LastName}="Charbeneau"; $NewContact->Save(); print "Added $name\n"; }

        And this to delete the names I don't like:

        $Contacts = $NameSpace->Folders("Personal Folders")->Folders("Contact +s")->{Items}; my $Cacharbes = $Contacts->Find("[LastName]=Charbeneau"); my $cnt = 0; while (1) { if ($Cacharbes->{FirstName} eq "Chuckles"){ $Cacharbes->Delete(); } $Cacharbes = $Contacts->FindNext() || last; }

        The thing is, the find and find next function only return a single item from the main collection.

        Each item in a Contacts folder collection has a unique ->{EntryID} property, but it's not something you can remmber off the top of your head.

        C-.