473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Outlook 2003: How to move from Item array to GetNext()


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...


May 4 '06 #1
4 2437
Nothing about the Items collection changed between versions. Did you install the PIAs for Office 2003?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"John A. Bailo" <ja*****@texeme.com> wrote in message news:V7******************************@speakeasy.ne t...

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...



May 4 '06 #2

I just installed them and added the reference to my project.

On compile:

This line:

if (objFolders.Item(i).Name == "Public Folders")
GeneralFolders = objFolders.Item(i);

Gives this error:

C:\Documents and Settings\jbailo\My Documents\pc298 Documents\Visual
Studio Projects\OutlookEmail\Email.cs(158):
'Microsoft.Office.Interop.Outlook.Folders' does not contain a definition
for 'Item'

Same exact error as before.

This code compiled under Outlook 2000

Sue Mosher [MVP-Outlook] wrote:
Nothing about the Items collection changed between versions. Did you install the PIAs for Office 2003?

May 4 '06 #3
Go into your references and make sure you've removed any reference to Outlook or Office other than the PIAs you've just installed.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"John A. Bailo" <ja*****@texeme.com> wrote in message news:44**************@texeme.com...

I just installed them and added the reference to my project.

On compile:

This line:

if (objFolders.Item(i).Name == "Public Folders")
GeneralFolders = objFolders.Item(i);

Gives this error:

C:\Documents and Settings\jbailo\My Documents\pc298 Documents\Visual
Studio Projects\OutlookEmail\Email.cs(158):
'Microsoft.Office.Interop.Outlook.Folders' does not contain a definition
for 'Item'



Same exact error as before.

This code compiled under Outlook 2000

Sue Mosher [MVP-Outlook] wrote:
Nothing about the Items collection changed between versions. Did you install the PIAs for Office 2003?

May 5 '06 #4
Sue Mosher [MVP-Outlook] wrote:
Go into your references and make sure you've removed any reference to Outlook or Office other than the PIAs you've just installed.


I did remove it.

I also found that there was a bug with the .GetNext() method for items
in folders. I could do a .GetFirst() and then a .GetNext() but all
subsequent .GetNext()'s in a loop would not run.

In my research, I found that there are bug reports (including at MS)
going all the way back to the Outlook 97 OM !

Anyway, I solved my problem by going with a foreach(System.Object _item
in myFolders) instead.
May 5 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: George McCullen | last post by:
I have an Outlook 2003 using Exchange Server 2003 Public Contacts Folder containing 20,000 Contacts. I am writing a VB .Net 2003 program that loops through all the contacts in a "for each oCt in...
7
by: Chris Thunell | last post by:
I'm trying to loop through an exchange public folder contact list, get some information out of each item, and then put it into a vb.net datatable. I run though the code and all works fine until i...
8
by: Li Pang | last post by:
Hi, I used following codes to pass a message item from CDO to Outlook. They worked fine when I used outlook 2000, but get an error of "Specified cast is not valid." when I used Outlook 2003....
4
by: Pieter | last post by:
Hi, On the pc of one of my clients (W2000, Office 2003) I'm getting sometimes an exception when moving (Move) a MailItem to an Outlook-Folder: The RPC server is not available. (Exception from...
2
by: Pieter | last post by:
Hi, I'm using a thight integration with Outlook 2003 (with an Exchange server) in my VB.NET (2005) application. Until now I'm using the Outlook Object Model, but it appears to be very slow, and...
1
by: dcd | last post by:
Hi all I'm using trying to get my app to read in all contacts in the contact folder of Outlook. I'm using the Outlook Security manager to stop the pop up warnings. Outlook version is...
4
by: Corey66 | last post by:
Hello! I think, I have one simple question for you guys, but I don't get the answer by myself! I would like to import all "Outlook - Contacts" into my application and when I use "foreach" it...
1
by: philmarsay | last post by:
I have some code that loops through all contacts in a contact folder (approx 3000), reads some details from each contact and uses that information to perform various functions. However, as the...
11
by: Bill Davy | last post by:
I am trying to edit Contacts in Outlook. This is so I can transfer numbers from my address book which is an Excel spreadsheet to my mobile phone. I came across the following snippet of code which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.