- 分享
- 0
- 人气
- 0
- 主题
- 2
- 帖子
- 259
- UID
- 311150
- 积分
- 251
- 阅读权限
- 14
- 注册时间
- 2010-4-6
- 最后登录
- 2013-12-9
- 在线时间
- 185 小时
|
Google MSDN
- using System;
- using System.Reflection; // to use Missing.Value
- //TO DO: If you use the Microsoft Outlook 11.0 Object Library, uncomment the following line.
- //using Outlook = Microsoft.Office.Interop.Outlook;
- namespace ReadContact
- {
- public class Class1
- {
- public static int Main(string[] args)
- {
- try
- {
- // Create the Outlook application.
- Outlook.Application oApp = new Outlook.Application();
- // Get the NameSpace information.
- Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
- // Log on by using a dialog box to choose the profile.
- oNS.Logon(Missing.Value, Missing.Value, true, true);
-
- // Alternate logon method that uses a specific profile.
- // TODO: If you use this logon method,
- // change the profile name to an appropriate value.
- //oNS.Logon("YourValidProfile", Missing.Value, false, true);
-
- // Get the default Contacts folder.
- Outlook.MAPIFolder oContacts = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
- // Get the Items collection from the folder.
- Outlook.Items oItems = (Outlook.Items)oContacts.Items;
- // Get the first contact item in the Items collection.
- Outlook.ContactItem oCt = (Outlook.ContactItem)oItems.GetFirst();
- // Output some common properties.
- Console.WriteLine(oCt.FullName);
- Console.WriteLine(oCt.Title);
- Console.WriteLine(oCt.Birthday);
- Console.WriteLine(oCt.CompanyName);
- Console.WriteLine(oCt.Department);
- Console.WriteLine(oCt.Body);
- Console.WriteLine(oCt.FileAs);
- Console.WriteLine(oCt.Email1Address);
- Console.WriteLine(oCt.BusinessHomePage);
- Console.WriteLine(oCt.MailingAddress);
- Console.WriteLine(oCt.BusinessAddress);
- Console.WriteLine(oCt.OfficeLocation);
- Console.WriteLine(oCt.Subject);
- Console.WriteLine(oCt.JobTitle);
- // Display the contact.
- oCt.Display(true);
- // Log off.
- oNS.Logoff();
- // Explicitly release objects.
- oCt = null;
- oItems = null;
- oContacts = null;
- oNS = null;
- oApp = null;
- }
- //Simple error handling.
- catch (Exception e)
- {
- Console.WriteLine("{0} Exception caught.", e);
- }
- //Default return value.
- return 0;
- }
- }
- }
复制代码 |
|