Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems accessing calendar items using Win32::OLE and CDO 1.2.1

0 views
Skip to first unread message

Aaron

unread,
Feb 14, 2002, 11:23:18 AM2/14/02
to
I'm attempting to access appointment items through CDO using
Win32::OLE. I've gotten pretty far, but I'm stuck in dealing with the
Messages collection. According to msdn (liars!) when I access an item
in the Messages Collection, if its an appointment item, its TYPE
property will be set to IPM.Appointment (this so far is true), *and*
it will have certain properties that a normal Message object doesn't
have, namely:

StartTime, EndTime, ReminderMinutesBeforeStart

you know... things that would be in an outloook appointment item, but
not in an outlook e-mail message.

So... here's what I've got so far...


#-----------------------------[START CODE]---------------------
# Sender's Name and Password

my $sender = "sender";
my $passwd = "password";

# Create a new MAPI Session
#
use Win32::OLE;
use Win32::OLE::Variant;
use Win32::OLE::NLS qw(:LOCALE);
use Win32::OLE::Const;

use Data::Dumper;

Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);
$session = Win32::OLE->new("MAPI.Session") or die
Win32::OLE->LastError();

# Attempt to log on.
my $err = $session->Logon($sender, $passwd);

my $infostores = $session->InfoStores();
my $infostore_item;

my $mailbox_infostore;
my $mailbox_infostore_id;


# Loop through available infostores
for (my $i = 1; $i <= $infostores->{COUNT}; $i++)
{
$infostore_item = $infostores->Item($i);

if ($infostore_item->{NAME} eq "Mailbox - Ibrahim, Aaron")
{
$mailbox_infostore = $infostore_item;
$mailbox_infostore_id = $infostore_item->{ID};
}
}

my $rootFolder = $mailbox_infostore->{ROOTFOLDER};
my $calendar_folder_id;

for ($i = 1; $i <= $rootFolder->Folders->{COUNT}; $i++)
{
if (uc($rootFolder->Folders($i)->{NAME}) eq "CALENDAR")
{
$calendar_folder_id = $rootFolder->Folders($i)->{ID}
}

}

my $calendarFolder = $session->GetFolder($calendar_folder_id,
$mailbox_infostore->{ID});


my $ole_constants = Win32::OLE::Const->Load("Microsoft CDO 1.21
Library");

my $message_id;
my $current_message;
for ($i = 1; $i <= $calendarFolder->Messages->{COUNT}; $i++)
{
$message_id = $calendarFolder->Messages($i)->{ID};

$current_message = $session->GetMessage($message_id);

foreach my $key (keys %{$current_message})
{
print $key . "=" . $current_message->{$key} . "\n";
}

exit;
}

$session->Logoff();

#-----------------------------[END CODE]---------------------


#-----------------------------[START OUTPUT]---------------------
Now... in that hash that I'm looping through at the end but stop short
(for brevity's sake)... there are no calendar items available!
Here's the output of the code (modified to keep my personal stuff
personal :-))


Application=Collaboration Data Objects
Parent=Win32::OLE=HASH(0x22792f0)
Session=Win32::OLE=HASH(0x22792a8)
Class=3
FolderID=#[one big'ol string]
StoreID=#[one big'ol string]
ID=#[one big'ol string]
Type=IPM.Appointment
Size=1917
Importance=1
Subject=Updated: Intranet/Internet Project Status Mtg.
Sender=Win32::OLE=HASH(0x2279368)
TimeSent=2/1/02 12:18:08 PM
TimeReceived=2/4/02 7:43:42 AM
Text=
Sent=1
Submitted=0
Unread=0
Signed=0
Encrypted=0
ReadReceipt=0
DeliveryReceipt=0
Conversation=
ConversationIndex=01C1AB446A9DD4F92DE6171A11D68D35005004B600D5008D4A3B60
ConversationTopic=Intranet/Internet Project Status Mtg.
Fields=Win32::OLE=HASH(0x227941c)
Recipients=Win32::OLE=HASH(0x2279380)
Attachments=Win32::OLE=HASH(0x2279428)
Categories=
TimeCreated=2/4/02 7:43:42 AM
TimeExpired=
Sensitivity=0
TimeLastModified=2/12/02 9:46:53 AM
#-----------------------------[END OUTPUT]---------------------


Now... you'll notice, there's no calendar item start time or end times
on that particular item. I checked in Outlook, it *does* have a start
and an end time, but why wouldn't it be accessible? According to the
API specs, if a message has a "type" property of API.Appointment (and
you'll notice this one does), then its automatically an
AppointmentItem Object with the approrpriate properties available.

I really don't want to go fishing through the "Fields" object and
figure out which item correlates to my start and end times for an
appoinment. Could someone give me a hand please? :-D

0 new messages