Progress!!! With a little bit of guess work, and adding the suggestions from this board, I have managed to get a rotine which now happily reads round all the folders and subfolders in my Outlook.

use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Outlook'; use Win32::OLE::Variant; use Time::Local; use POSIX; #open the Outlook program my $outlook; eval { $outlook = Win32::OLE->GetActiveObject('Outlook.Application') }; if ($@ || !defined($outlook)) { $outlook = Win32::OLE->new('Outlook.Application', sub {$_[0]->Quit;} +) or die "oops\n"; } my $namespace = $outlook->GetNameSpace("MAPI") or die "can't open MAPI + namespace\n"; my $Folder; my $subfoldernm = "Calendar"; my $sheetcnt = $namespace->Folders->Count(); foreach (1..$sheetcnt){ $Folder = $namespace->Folders($_)->{Name}; print "\n\t No.". $_ ." Folder Name - >" .$Folder ."<\n"; print "\n\t\tNo.\tItems\tItems"; my $subfldrcnt = $namespace->Folders($Folder)->Folders()->Count or +my $dummy = "true"; foreach (1..$subfldrcnt){ my $subfolder = $namespace->Folders($Folder)->Folders($_)->{Nam +e} or die "cant access folder $Folder"; my $itemcnt = $namespace->Folders($Folder)->Folders($subfolder) +->Items()->Count or my $empty = "true"; print "\n\t\t$_\t$itemcnt\t$subfolder"; } }
I now need to work out how to store a calendar entry away. I guess this means a two part task. Firstly to "select" the correct calendar folder to store the entry in, secondly to generate the entries to store away.

From the results of my current routine, I can see that for testing purposes, the folder I need is "Personal Folders" and the subfolder is "Calendar"

I'm thinking that some code along the lines of :-
my $cal = new Win32::OLE('Outlook.Application'); $cal->{'Visible'} = 1; my $item = $cal->CreateItem(0); $item->{'Subject'} = "perl test"; $item->{'Location'} = "Test Location"; $item->{'Start'} = "04/30/2002 12:00"; $item->{'End'} = "04/30/2002 12:30"; my $selectfolder = $namespace->Folders($Folder)->Folders($subfo +lder)->Items()->Add($item) or " **** can't add item";


but I suspect this is only the half of it.

As before, does anyone have any ideas?

I did find some code to generate an e-mail entry, and am thinking that the code to generate a calendar entry wouldn't be that dissimilar.
#my $mail = new Win32::OLE('Outlook.Application'); #$mail->{'Visible'} = 1; #my $item = $mail->CreateItem(0); #$item->{'Subject'} = "This is a test"; #$item->{'To'} = "david.booth\@easynet.co.uk"; #$item->{'Body'} = "Here is the meat of the message"; #$item->Send(); #$mail->Quit();

As ever any suggestions as to how best doing this will be most gratefully received

In reply to Re: Re: Re(5): Creating entries in an Outlook Calendar by lumina
in thread Creating entries in an Outlook Calendar by lumina

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.