我试图将Outlook联系人的联系人转换为C#,但它无法正常工作.我使用过Microsoft Outlook 12.0对象库.我想在richtextbox或gridview中显示数据.
代码粘贴在下面.请让我知道我应该在那里做什么.
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.olFolderContacts);
// 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];
richTextBox1.Text += contact.FullName + " (" +
contact.BusinessTelephoneNumber + ")" + …Run Code Online (Sandbox Code Playgroud)