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
}
}
}
> 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
[quoted text clipped - 7 lines]
> Are there any good examples of accessing AddressBook from C# out there?
> Thanks