how to add a new contact from c#?

S

Sam Jost

I can attach to Outlook and read the contacts from any folder with this
source:

Outlook.Application outlookApp = new Outlook.Application();
Outlook.NameSpace outlookNamespace = outlookApp.GetNamespace("mapi");
outlookNamespace.Logon("SR", "", true, true);
Outlook.MAPIFolder cContacts = outlookNamespace.PickFolder();
foreach (Outlook.ContactItem outlookKontakt in cContacts.Items)
{
Console.WriteLine(outlookKontakt.FullName);
}
outlookNamespace.Logoff();


But now I'd like to change fields in these contacts, or add a new contact.

Can someone point me to some hints/docs how to add new contacts via COM, or
how to change stuff in the contacts?

thanks!
Sam
 
S

Sam Jost

I had been a bit hasty to post my question, now I found the solution to my
problem.

thanks anyway for collective thinking :)

Sam
 
R

robin

Please help.
I have used VB for outlook auomation an am trying to use c#, but I
can't seem to get foreach to work in this way, but vb is fine...

outlook2002, gives

Form1.cs(103): foreach statement cannot operate on variables of type
'Outlook.Items' because 'Outlook.Items' does not contain a definition
for 'GetEnumerator', or it is inaccessible

Does anyone have any ideas ?

Cheers
Robin
 
O

Oz Kologlu

Use items.GetNext()

Oz


Please help.
I have used VB for outlook auomation an am trying to use c#, but I
can't seem to get foreach to work in this way, but vb is fine...

outlook2002, gives

Form1.cs(103): foreach statement cannot operate on variables of type
'Outlook.Items' because 'Outlook.Items' does not contain a definition
for 'GetEnumerator', or it is inaccessible

Does anyone have any ideas ?

Cheers
Robin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top