Just to note: I tried the following code, and it does crash after adding 250
contact items, too.
The only difference it made is there was no contact created in the default
contact folder, so it is a tad bit better. But not much
Outlook.ContactItem newItem =
(Outlook.ContactItem)outlookKontaktFolder.Items.Add("IPM.Contact");
newItem.LastName= "Jost";
newItem.FirstName= "Sam";
newItem.Close(Outlook.OlInspectorClose.olSave);
Sam
"Sam Jost" <(E-Mail Removed)> wrote:
> Hi,
>
> I'm writing a little c# program to import contacts into outlook. It is
> simple enough to add a new contact like this:
>
> Outlook.ContactItem newItem =
> (Outlook.ContactItem)outlookApp.CreateItem(Outlook.OlItemType.olContactItem);
> newItem.LastName= "Jost";
> newItem.FirstName= "Sam";
> newItem.Close(Outlook.OlInspectorClose.olSave);
>
> this code snipped does work nicely, even for a few hundrets of contacts.
>
> My problem is, I'd like to add these contacts not in the standard folder
> but in some other. When I try using Move() to put the contacts into the
> destination folder like this it does work for about 200 contacts before I
> get an exception
>
> Outlook.ContactItem newItem =
> (Outlook.ContactItem)outlookApp.CreateItem(Outlook.OlItemType.olContactItem);
> newItem.LastName= "Jost";
> newItem.FirstName= "Sam";
> newItem.Move(MyOutlookKontaktFolder);
> newItem.Close(Outlook.OlInspectorClose.olDiscard);
>
> Error : Client-Exception.
> at Outlook._ContactItem.Move(MAPIFolder DestFldr)
> at OutlookExporter.Class1.Sync() in
> c:\pw\outlookexporter\outlookexporter.cs:line 197
>
> And the last contact will be in the default folder instead of the
> destination folder.
>
> My guess is I'm using Move() incorrectly, or miss something like Dispose()
> (that I cant find on these classes) so I got a memory leak or something.
>
> Can anyboy help me here, or point me somewhere I can get help?
>
> thanks,
> Sam
>