Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Interop / September 2005

Tip: Looking for answers? Try searching our database.

how to add a new contact from c#?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sam Jost - 17 Dec 2004 13:21 GMT
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
Sam Jost - 17 Dec 2004 13:38 GMT
I had been a bit hasty to post my question, now I found the solution to my
problem.

thanks anyway for collective thinking :)

Sam

>I can attach to Outlook and read the contacts from any folder with this
>source:
[quoted text clipped - 16 lines]
> thanks!
> Sam
robin@Xfinlow.co.uk - 20 Sep 2005 15:03 GMT
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

>I had been a bit hasty to post my question, now I found the solution to my
>problem.
[quoted text clipped - 23 lines]
>> thanks!
>> Sam
Oz Kologlu - 21 Sep 2005 00:56 GMT
Use items.GetNext()

Oz

> Please help.
> I have used VB for outlook auomation an am trying to use c#, but I
[quoted text clipped - 39 lines]
>>> thanks!
>>> Sam
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.