Problem Reading Collection in ActiveX

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Problem Reading Collection in ActiveX

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:07 pm

by hml >> Tue, 9 Apr 2002 9:42:00 GMT

I am trying to read a mail from Outlook 2000, and have imported the Outlook ActiveX library and written the following code:

readOutlookMail();

vars
lNamespace : I_NameSpace;
lOutlook : Application_1;
lFolder : MAPIFolder;
lItem : I_Items;
i : Integer;

begin
create lOutlook transient;

lNamespace := lOutlook.getNamespace("MAPI");
lNamespace.logon ("", "", false, false);

lFolder := lNamespace.getDefaultFolder(6);

write lFolder.items.count;

foreach i in 1 to lFolder.items.count do
write lFolder.items;

lItem := lFolder.items.item(1).I_Items;
endforeach;
end;

The above code will read from Outlook, and the first write (lFolder.items.count) will return the correct number of mail items in the Inbox. The second write (lFolder.items) shows that the collection within lFolder.items is of type I_Items.

My problem is when trying to get at one of the objects in the lFolder.items collection (lItem := lFolder.items.item(1).I_Items) I get the following message: "Class of object is invalid in this context." I get this error even though I know that the items are of the correct type.

Can anyone tell me why I get this message, and how I can get around it? I am using Jade 5.2.08

Thanks

Tim

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Problem Reading Collection in ActiveX

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:07 pm

by cdshearer >> Tue, 9 Apr 2002 9:52:56 GMT

Hi Tim

I don't know... maybe this is a bug, but maybe you're just making a mistake. How do you *know* that the object returned by the line:

lFolder.items.item(1)

is actually of type I_Items?

From the name of the class, it looks to me that I_Items is a collection, not a single "Item" object but then, some of these active-X imports do have funny/inappropriate names. Why don't you write the following instead:

write lFolder.items.item(1);

then you will see exactly what the type is. If it *is* in fact of type I_Items then this looks like a bug in JADE, but I suspect not...

Let us know.

Regards,
Craig Shearer

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Problem Reading Collection in ActiveX

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:07 pm

by hml >> Wed, 10 Apr 2002 13:16:47 GMT

lFolder.items contains the contents of the Outlook Inbox. So this could contain folders and mail items. I know that lFolder.items contains only mail items as the count contains the total number of mails in the Inbox, and I have no folders in the Inbox folder.

The problem is, Jade will not allow me to type cast lFolder.items.item(1), so I can not get at the details of the mail items (subject, text, etc.).

I know that this code should work, as I have done it in VB. lFolder.items.item(1) is of type IDispatch, and VB will allow it to be type cast while Jade does not.

Thanks

Tim

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Problem Reading Collection in ActiveX

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:07 pm

by wxv >> Thu, 11 Apr 2002 3:26:26 GMT

From what I understand, Jade does not let you type-cast COM objects, which is a pain when dealing with collections that hold & return different types objects. I had the same problem with the MS XML API, trying casting cast one object (a "Node" returned by a collection) to the object which i actually knew it was (an "Element").

It would be nice if Jade was a lot more "loose" with COM types, and made it easier to cast one to the other. This would get around these limitations.

Then again, im using an old version of Jade and this might already be fixed?


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 50 guests

cron