A
Anonymous
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Outlook;
namespace PrintContacts
{
class Program
{
static void Main(string[] args)
{
Application outlook = new Application();
NameSpace ns = outlook.GetNamespace("MAPI");
MAPIFolder cf = ns.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
foreach (object o in cf.Items)
{
if ((o as ContactItem) != null)
{
ContactItem ci = (ContactItem)o;
Console.WriteLine(ci.FullName);
}
}
}
}
}
--> After listed about hundred contacts I get the error:
System.Runtime.InteropServices.COMException (0xB5940305): [localized
message - something like "to many open objects on the exchange server"].
vid Microsoft.Office.Interop.Outlook._ContactItem.get_FullName()
vid PrintContacts.Program.Main(String[] args) i
C:\PrintContacts\Program.cs
How can I prevent this?
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Outlook;
namespace PrintContacts
{
class Program
{
static void Main(string[] args)
{
Application outlook = new Application();
NameSpace ns = outlook.GetNamespace("MAPI");
MAPIFolder cf = ns.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
foreach (object o in cf.Items)
{
if ((o as ContactItem) != null)
{
ContactItem ci = (ContactItem)o;
Console.WriteLine(ci.FullName);
}
}
}
}
}
--> After listed about hundred contacts I get the error:
System.Runtime.InteropServices.COMException (0xB5940305): [localized
message - something like "to many open objects on the exchange server"].
vid Microsoft.Office.Interop.Outlook._ContactItem.get_FullName()
vid PrintContacts.Program.Main(String[] args) i
C:\PrintContacts\Program.cs
How can I prevent this?