Accessing Addressbook from InfoPath

C

cebess

I'd like to have the user enter personnel information using the Address book
dialog from outlook from within Infopath. I figured out how to do something
similar from LDAP, but most users are used to selecting people from outlook,
so I'd like to use that instead.

Unfortunately, all the examples I can find are in VB6, which are difficult
to implement from a .NET based language like C#, since I can't find all the
intervening class definitions.

Are there any good examples of accessing AddressBook from C# out there?
Thanks
 
C

cebess

Here is a console app that is much closer to what I was trying to do:
using System;

using MAPI;

namespace ConsoleApplicationOurlook

{

/// <summary>

/// Summary description for Class1.

/// </summary>

class Class1

{

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main(string[] args)

{

//

// TODO: Add code to start application here

//

MAPI.SessionClass oSession = new MAPI.SessionClass();

//oSession.Logon(System.Environment.UserName,
System.Reflection.Missing.Value, true, true,
System.Reflection.Missing.Value, false, System.Reflection.Missing.Value);

oSession.Logon(System.Reflection.Missing.Value,
System.Reflection.Missing.Value, true, false,
System.Reflection.Missing.Value,true, System.Reflection.Missing.Value);

MAPI.Recipients oRecipients = null;

MAPI.Recipient oRecipient = null;

MAPI.AddressEntry oAddressEntry = null;

//oRecipients =
(MAPI.Recipients)oSession.AddressBook(System.Reflection.Missing.Value,
"Select Name", true, true, -1, "", "", "", 0);

oRecipients =
(MAPI.Recipients)oSession.AddressBook(System.Reflection.Missing.Value,
"Select Name", true, true, -1, "", "", "", 0);

for(int i = 1; i <= (int)oRecipients.Count; i++)

{

// Do what you need with Recipient, or AddressEntry

oRecipient = (MAPI.Recipient)oRecipients.get_Item(i);

oAddressEntry = (MAPI.AddressEntry)oRecipient.AddressEntry;

string addressString = oAddressEntry.Address.ToString();

#if DEBUG

System.Console.WriteLine(addressString);

#endif


}

oSession.Logoff();

System.Console.ReadLine(); // wait to see what happens

}

}

}
 

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