PC Review


Reply
Thread Tools Rate Thread

how to add new contacts via COM

 
 
Sam Jost
Guest
Posts: n/a
 
      20th Dec 2004
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


 
Reply With Quote
 
 
 
 
Sam Jost
Guest
Posts: n/a
 
      20th Dec 2004
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
>



 
Reply With Quote
 
Sam Jost
Guest
Posts: n/a
 
      21st Dec 2004
Dang, found the cause of my problem:

After creating 250 Mapi objects I get the following log error:
Event ID: 9646
Type: Error
Source: MSExchangeIS
Description:
Closing Mapi session "/o=Organization/ou=Administrative
Group/cn=Recipients/cn=user" because it exceeded the maximum of 250 objects
of type "objMessage".

What can I do in my program to work around this 250 limitation? I might
close the connection every 250 items, but it seems wrong to me, ain't there
some better way to flush the items to the server and thus reduze the count
of objects?

Sam

"Sam Jost" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Synchronize Contacts Between BCM Contacts and Personal Contacts Jon Maxim Microsoft Outlook BCM 0 2nd Sep 2009 06:51 PM
Contacts in Personal Contacts sync with those in Business Contacts mmullin Microsoft Outlook BCM 6 10th Feb 2009 03:47 PM
Quick find in contacts cannot locate some contacts in large address book (over 1300 contacts) thomas8@gmail.com Microsoft Outlook Contacts 1 27th Sep 2007 05:42 PM
How do I move contacts from contacts to business contacts? =?Utf-8?B?VG9kZCBGaXR6?= Microsoft Outlook BCM 3 13th Apr 2007 11:24 PM
How do I COPY contacts from my contacts TO the buisness contacts =?Utf-8?B?TE1UIDE=?= Microsoft Outlook BCM 1 7th Apr 2006 09:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:05 AM.