Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.

Re(3): Creating entries in an Outlook Calendar

by dmmiller2k (Chaplain)
on Apr 20, 2002 at 23:05 UTC ( #160819=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Creating entries in an Outlook Calendar
in thread Creating entries in an Outlook Calendar

Why don't you enumerate the items in the 'Folders' collection? Each of those is a folder with its own items. See OL2000: Programming Examples for Referencing Items and Folders in Microsoft's knowledge base for more on this.

Good question, though.


If you GIVE a man a fish you feed him for a day
TEACH him to fish and you feed him for a lifetime

Replies are listed 'Best First'.
Re: Re(3): Creating entries in an Outlook Calendar
by lumina (Novice) on Apr 22, 2002 at 13:46 UTC
    Again, thanks for the reply.
    Well I looked at the suggested reference, but only programming in Perl for a couple of weeks now, it just didn't make sense. I've had 18 years of proramming in Cobol on mainframes and converting to Perl is just fantastic. I've stumbled through generating e-mails and SMS messages OK. I've even been able to look up entries in an access datbase, mostly using code which I have cribbed from this website.
    I just can't figure out where to start on evaluating the folders collection, so if anyone could point me in the right direction I would be most grateful. If I can get them evaluated, then presumably it might give me a clue as to what my target folder is called. Then I can get on with writing the entries I have already extracted, back into that folder.

      If you haven't already, take a look at the article I referenced in my earlier message. You should also view the Win32::OLE docs.

      The short answer is that once you have the 'folders' object (or any collection), you can index it like an array. To wit:

      # from your own example my $outlook = new Win32::OLE('Outlook.Application'); my $ns = $outlook->GetNameSpace("MAPI") or die "can't open MAPI namesp +ace\n"; my $folders = $ns->Folders(); # get the folders collection foreach my $folder (in @$folders) { # here $folder will be set to each folder in turn }

      Hope this helps ..


      If you GIVE a man a fish you feed him for a day
      TEACH him to fish and you feed him for a lifetime
        Thanks guys, and humble apologies for being such a nugget. I had my personal options for set to the default of three levels, so I couldn't see that you had replied. It's sorted now, so am off and running again. duh!

        I had already managed to get a list of the folders at the top level using code similar to what you suggested namely
        my $Folder = $namespace->Folders("Personal Folders"); my $Items = $Folder->Items; my $sheetcnt = $namespace->Folders->Count(); foreach (1..$sheetcnt){ $Folder = $namespace->Folders($_)->{Name}; print "\t" .$Folder ."\n"; # my $subfolder = $namespace->Folders($Folder)->MAPIFolder->Count(); # foreach (1..$subfolder){ # print "\t" .$namespace->Folders($Folder)->MAPIFolder($_)->{Name +}. "\n"; # } }

        The commented out lines are my attempt to get to the next level down, which should be the list of folders, including inbox, outbox, calendar etc. etc. however if the commented out code is reinstated, it fails. with 'Can't call method "Count" on an undefined value at .......' which is the line
        my $subfolder = $namespace->Folders($Folder)->MAPIFolder->Count();
        Having checked the Outlook Object Model from the reference helpfully supplied by this site, MAPIFolder does seem to be the next level down, so I am not sure where I am going wrong.
        Any ideas?
Re: Re(3): Creating entries in an Outlook Calendar
by Anonymous Monk on Apr 21, 2002 at 09:42 UTC
    Thanks again, I have only been learning perl for a couple of weeks, so evaluating the folders collection is still beyond my slowly expanding perl skills.
    Is there any chance you could give me an idea as to how to do this?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2023-09-21 08:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found