Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Re: Re: Check your property Names in the Outlook ContactItem Class

by cacharbe (Curate)
on May 24, 2002 at 15:32 UTC ( [id://169110]=note: print w/replies, xml ) Need Help??


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

Null Perspiration.

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

C-.

  • Comment on Re: Re: Re: Check your property Names in the Outlook ContactItem Class

Replies are listed 'Best First'.
Re: Re: Re: Re: Check your property Names in the Outlook ContactItem Class
by Anonymous Monk on May 29, 2002 at 16:50 UTC
    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-.

        This is very good - however what happens if Charbeneau does not exist in the contacts file. Can I do some sort of Last Name = C* to get to the beginning of the C's and then FindNext or how the the error condition be handled if there is not match. What I am attempting to do is allow my cgi to update this contacts file from our intranet. Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://169110]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-24 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found