473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Get Contacts from Outlook 2007 in C#?

Hi
Is there a easy way to get the contacts (names and phonenumbers) from
outlook without the message that someone is accessing outlook and how long
the access can take?

i have not found any working solution for that :(

thanks for any help
Volkan
Sep 25 '08 #1
3 3365
I founded a way how to get this, here is it at a demo app:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace Contacter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void getContacts_Click(object sender, EventArgs e)
{
// Obtain an instance of the Outlook application
Outlook.Application app = new Outlook.ApplicationClass();

// Access the MAPI namespace
Outlook.NameSpace ns = app.GetNamespace("MAPI");

// Get the user's default contacts folder
Outlook.MAPIFolder contacts =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFol derContacts);

// Iterate through each contact
for (int i = 1; i < contacts.Items.Count + 1; i++)
{
// Get a contact
Outlook.ContactItem contact =
(Outlook.ContactItem)contacts.Items[i];
txtResults.Text += contact.FullName + " (" +
contact.BusinessTelephoneNumber + ")" + Environment.NewLine;
Application.DoEvents();
}
}
}
}
thx
Volkan
"Volkan Senguel" <mo******@2wire.chschrieb im Newsbeitrag
news:OU**************@TK2MSFTNGP04.phx.gbl...
Hi
Is there a easy way to get the contacts (names and phonenumbers) from
outlook without the message that someone is accessing outlook and how long
the access can take?

i have not found any working solution for that :(

thanks for any help
Volkan


Sep 25 '08 #2
What kind of project did you make that in? What references did you add to
make it work?

"Volkan Senguel" <mo******@2wire.chwrote in message
news:uX**************@TK2MSFTNGP06.phx.gbl...
>I founded a way how to get this, here is it at a demo app:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace Contacter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void getContacts_Click(object sender, EventArgs e)
{
// Obtain an instance of the Outlook application
Outlook.Application app = new Outlook.ApplicationClass();

// Access the MAPI namespace
Outlook.NameSpace ns = app.GetNamespace("MAPI");

// Get the user's default contacts folder
Outlook.MAPIFolder contacts =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFol derContacts);

// Iterate through each contact
for (int i = 1; i < contacts.Items.Count + 1; i++)
{
// Get a contact
Outlook.ContactItem contact =
(Outlook.ContactItem)contacts.Items[i];
txtResults.Text += contact.FullName + " (" +
contact.BusinessTelephoneNumber + ")" + Environment.NewLine;
Application.DoEvents();
}
}
}
}
thx
Volkan
"Volkan Senguel" <mo******@2wire.chschrieb im Newsbeitrag
news:OU**************@TK2MSFTNGP04.phx.gbl...
>Hi
Is there a easy way to get the contacts (names and phonenumbers) from
outlook without the message that someone is accessing outlook and how
long the access can take?

i have not found any working solution for that :(

thanks for any help
Volkan



Sep 25 '08 #3
Its a Winform project, and the only refference is the
Microsoft.Office.Interop.Outlook (Microsoft Outlook 12.0 Object Library)
com object.

Yes it works flawless ;)

greets
Volkan

"Berryl Hesh" <ef******@yahoo.comschrieb im Newsbeitrag
news:JF*******************@newsfe03.iad...
What kind of project did you make that in? What references did you add to
make it work?

"Volkan Senguel" <mo******@2wire.chwrote in message
news:uX**************@TK2MSFTNGP06.phx.gbl...
>>I founded a way how to get this, here is it at a demo app:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace Contacter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void getContacts_Click(object sender, EventArgs e)
{
// Obtain an instance of the Outlook application
Outlook.Application app = new Outlook.ApplicationClass();

// Access the MAPI namespace
Outlook.NameSpace ns = app.GetNamespace("MAPI");

// Get the user's default contacts folder
Outlook.MAPIFolder contacts =
ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderContacts);

// Iterate through each contact
for (int i = 1; i < contacts.Items.Count + 1; i++)
{
// Get a contact
Outlook.ContactItem contact =
(Outlook.ContactItem)contacts.Items[i];
txtResults.Text += contact.FullName + " (" +
contact.BusinessTelephoneNumber + ")" + Environment.NewLine;
Application.DoEvents();
}
}
}
}
thx
Volkan
"Volkan Senguel" <mo******@2wire.chschrieb im Newsbeitrag
news:OU**************@TK2MSFTNGP04.phx.gbl...
>>Hi
Is there a easy way to get the contacts (names and phonenumbers) from
outlook without the message that someone is accessing outlook and how
long the access can take?

i have not found any working solution for that :(

thanks for any help
Volkan





Sep 26 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Brian Hampson | last post by:
I recently upgraded to Outlook 2007 B2TR and have found that I can no longer code against MAPI.DLL It's gone :( Using C#, I used to get the MAPI session, and from that I could change the out of...
1
by: tomer.ha | last post by:
Hi there, I'd like to send emails from a Python program using Simple MAPI. I've tried this code: http://mail.python.org/pipermail/python-list/2004-December/298066.html and it works well with...
0
by: =?Utf-8?B?Uy5IZXJy?= | last post by:
I am running Outlook 2007 using the most recent version of Outlook Connector on a Windows Vista operating system. I use the Windows Live Mail and can send messages from Outlook, but cannot...
2
by: Brad Isaac | last post by:
Hi, I have a working app that uses interop.outlook.dll to export items to Outlook calendar. I downloaded the Primary Interop Assemblies for Office 2k7 today and still cannot get a working...
0
by: John | last post by:
Hi An outlook 2003 add-in solution created in vs 2008 on a pc with outlook 2007 when re-opened in vs 2008 brings up the conversion wizard. Cancelling wizard closes solution and does not allow to...
1
by: =?Utf-8?B?ZHRvd24gT3V0bG9vayAyMDA3IGNyYXNo?= | last post by:
Outlook 2007 keeps freezing on startup. I am running Vista Home Premium. I need to get back to work- please HELP! Outlook will appear to start but it locks into "Updating cached messages......
0
by: lundmark | last post by:
When I send a plain-text message using Outook 2007, I want hard line breaks to be added to my outgoing message. I cannot seem to make this happen. I have configured Outlook to Automatically wrap...
0
by: gowthamkg | last post by:
hi, I want read contacts in Particular Distribution List in outlook 2007 using C#(visual studio 2008)...i'm able to create to new distribution list and add members..How to retrieve them...
4
by: infomage27 | last post by:
I have tried scripting this with rules and VBA, now trying with C# but still failing. (code is exploratory, so please excuse the terribleness) maybe someone here will show me the error of my...
0
by: Dave Waine | last post by:
If I right click on a .jpg file and select 'send to email recipient' I am asked if I want to reduce file size but Windows doesn't then open Outlook 2007 to send the file (as an attachment). {Windows...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.