PC Review


Reply
Thread Tools Rate Thread

how to add a new contact from c#?

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


 
Reply With Quote
 
 
 
 
Sam Jost
Guest
Posts: n/a
 
      17th Dec 2004
I had been a bit hasty to post my question, now I found the solution to my
problem.

thanks anyway for collective thinking

Sam


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



 
Reply With Quote
 
robin@Xfinlow.co.uk
Guest
Posts: n/a
 
      20th Sep 2005
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

On Fri, 17 Dec 2004 14:38:17 +0100, "Sam Jost" <(E-Mail Removed)>
wrote:

>I had been a bit hasty to post my question, now I found the solution to my
>problem.
>
>thanks anyway for collective thinking
>
>Sam
>
>
>"Sam Jost" <(E-Mail Removed)> schrieb im Newsbeitrag
>news:upah%(E-Mail Removed)...
>>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
>>

>


 
Reply With Quote
 
Oz Kologlu
Guest
Posts: n/a
 
      21st Sep 2005
Use items.GetNext()

Oz


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
> On Fri, 17 Dec 2004 14:38:17 +0100, "Sam Jost" <(E-Mail Removed)>
> wrote:
>
>>I had been a bit hasty to post my question, now I found the solution to my
>>problem.
>>
>>thanks anyway for collective thinking
>>
>>Sam
>>
>>
>>"Sam Jost" <(E-Mail Removed)> schrieb im Newsbeitrag
>>news:upah%(E-Mail Removed)...
>>>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
>>>

>>

>



 
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
Contact address appears in Contact folder but not when choosing contact to forward message to. Peter Microsoft Outlook Contacts 6 12th Apr 2010 02:56 PM
How do I import a Windows Contact(.Contact) to an Outlook Contact Timothy Microsoft Outlook Contacts 1 13th Sep 2009 07:39 PM
Using Outlook Contact Information to Send a Letter to a Contact using a Custom Word Template Rik Microsoft Access Macros 0 5th Apr 2005 12:27 AM
Upon receipt of email, Outlook XP changes Contact Sender name to first Contact with the email address associated with the Contact name Paul Billings Microsoft Outlook Contacts 1 11th Nov 2004 10:10 AM
Contact in Contact folder not available in contact address book =?Utf-8?B?ZWxlY2F0ZXM=?= Microsoft Outlook Contacts 0 10th Nov 2004 06:29 PM


Features
 

Advertising
 

Newsgroups
 


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