Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: Outlook.MAPIFolder: for each compile error

Geek News

Outlook.MAPIFolder: for each compile error
"spareway" <spareway[ at ]gmail.com> 1/28/2007 6:16:13 PM
When I try to compile this:

foreach (Outlook.MAPIFolder tmpFolder in theFolder.Folders)
{
MesageBox.Show(tmpFolder.Name);
}


I get this:

foreach statement cannot operate on variables of type
'Outlook.Folders' because 'Outlook.Folders' does not contain a
definition for 'GetEnumerator', or it is inaccessible

Anyone know what is the problem?

thanks,

craig

Re: Outlook.MAPIFolder: for each compile error
"Ken Slovak - [MVP - Outlook]" <kenslovak[ at ]mvps.org> 1/29/2007 2:05:03 PM
The problem is you can't use foreach, as the error says. Use a for loop
instead. It's actually faster anyway.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"spareway" <spareway[ at ]gmail.com> wrote in message
news:1170008173.762947.85420[ at ]k78g2000cwa.googlegroups.com...
[Quoted Text]
> When I try to compile this:
>
> foreach (Outlook.MAPIFolder tmpFolder in theFolder.Folders)
> {
> MesageBox.Show(tmpFolder.Name);
> }
>
>
> I get this:
>
> foreach statement cannot operate on variables of type
> 'Outlook.Folders' because 'Outlook.Folders' does not contain a
> definition for 'GetEnumerator', or it is inaccessible
>
> Anyone know what is the problem?
>
> thanks,
>
> craig
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net