J
John A. Bailo
After upgrading from Outlook 2000 to the 2003 object model, some of my
Outlook automation code no longer functions.
For example, in 2000, I used to be able to loop through a list of .Items
in a folder and refer to each as .Item(n)
Say for example, my folder contained MailItem and PostItem -- I could
treat each differently by casting .Item(n) differently.
if(myFolder.Items.Item(2) is Outlook.PostItem)
Outlook.PostItem myPI =
(Outlook.PostItem) myFolder.Items.Item(2);
But, now there is no more Item -- there is .GetNext()
However, what generic object type can I cast the return object of
..GetNext() to before using .GetType() to see what object type it is?
Or do I have to do, .GetNext() and then a .GetPrevious() ?
Example:
if(myFolder.Items.GetNext().GetType() is PostItem)
Outlook.PostItem myPI =
(Outlook.PostItem) myFolder.Items.GetPrevious();
....seems like wasteful enumeration, iteration...
Outlook automation code no longer functions.
For example, in 2000, I used to be able to loop through a list of .Items
in a folder and refer to each as .Item(n)
Say for example, my folder contained MailItem and PostItem -- I could
treat each differently by casting .Item(n) differently.
if(myFolder.Items.Item(2) is Outlook.PostItem)
Outlook.PostItem myPI =
(Outlook.PostItem) myFolder.Items.Item(2);
But, now there is no more Item -- there is .GetNext()
However, what generic object type can I cast the return object of
..GetNext() to before using .GetType() to see what object type it is?
Or do I have to do, .GetNext() and then a .GetPrevious() ?
Example:
if(myFolder.Items.GetNext().GetType() is PostItem)
Outlook.PostItem myPI =
(Outlook.PostItem) myFolder.Items.GetPrevious();
....seems like wasteful enumeration, iteration...