Outlook 연락처의 연락처를 C#으로 가져 오려고했지만 작동하지 않습니다. 필자는 Microsoft Outlook 12.0 Object Library를 사용했습니다. richtextbox 또는 gridview에 데이터를 표시하려고합니다.Outlook 연락처를 C# 폼 기반 응용 프로그램으로 가져 오기
코드는 아래에 붙여 넣습니다. 제가 여기서해야 할 일을 알려주세요.
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 + ")" + Environment.NewLine;
Application.DoEvents();
}
}
}
'작동하지 않는'부분에 대한 자세한 정보를 제공 할 수 있습니까? –
버튼 이벤트가 발생합니다! 그것은 전혀 아무것도하지 않는다! 그것은 gridview에 Outlook의 연락처를 표시해야하지만! – user2420211
AH! 아무 것도 일어나지 않으면 단추의 '클릭'이벤트를 처리기에 연결해야합니다. Xaml에서 그렇게 할 수 있습니다. –