Wrox Programmer Forums
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 15th, 2004, 07:38 AM
Registered User
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Outlook and C# Doubt


I am woking with Outlook and c#. I have Outlook 2000 installed on my machine. And hence I have Microsoft Outlook 9.0 Object Library (msoutl9.olb).

I am using the following code to access each item in the default outbox folder. I am not able to access individual items in the collection. I am getting the following error:

F:\PracFold\mydotnet\myc#\prthree\sol_three\prj_th ree\Form1.cs(142): foreach statement cannot operate on variables of type 'Outlook.Items' because 'Outlook.Items' does not contain a definition for 'GetEnumerator', or it is inaccessible

Is the Outlook.Items collection not supported by Outlook 2000 ???

My code is :

public void button1_Click(object sender, System.EventArgs e)
        Outlook.Application oApp = new Outlook.Application();
        Outlook._NameSpace oNameSpace = oApp.GetNamespace("MAPI");
        Outlook.MAPIFolder oOutboxFolder = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolde rs.olFolderOutbox);

        MessageBox.Show("There are " + oOutboxFolder.Items.Count.ToString() + " items in the Outbox.","Mails in Outbox");

        Outlook.Items olMailItems = oOutboxFolder.Items;

        foreach(Outlook.MailItem olMail in olMailItems)

    catch(Exception ex)
        MessageBox.Show(ex.Message,"Prasad, an error occured !!!");

Please help me with this ...

Prasad P

Similar Threads
Thread Thread Starter Forum Replies Last Post
Doubt hamnapalakkal Crystal Reports 0 February 4th, 2008 12:27 AM
doubt somavenki .NET Framework 2.0 2 February 3rd, 2008 11:29 AM
doubt sampathk Visual Basic 2005 Basics 1 November 28th, 2006 02:45 PM
doubt! kk_katepally ASP.NET 1.0 and 1.1 Basics 1 February 7th, 2006 01:58 PM
doubt naveen J2EE 1 April 6th, 2004 07:42 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.