1
Reply

Outlook and C# problem :(

peesapati

peesapati

Apr 15 2004 9:09 AM
1.7k
Hi 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_three\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) { try { Outlook.Application oApp = new Outlook.Application(); Outlook._NameSpace oNameSpace = oApp.GetNamespace("MAPI"); oNameSpace.Logon(null,null,false,true); Outlook.MAPIFolder oOutboxFolder = oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.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) { MessageBox(olMail.To.ToString()); } oNameSpace.Logoff(); } catch(Exception ex) { MessageBox.Show(ex.Message,"Prasad, an error occured !!!"); } } Please help me with this. Prasad P

Answers (1)