怎样导出outlook里面的联系人信息  
本地的 和服务器的 
能不能提供下源代码

解决方案 »

  1.   

    取服务器数据需要涉及到Exchange知识,在此提供本地获取
    以前做的Outlook插件.using System;
    using System.Data;
    using Outlook = Microsoft.Office.Interop.Outlook;
    using System.Collections.Generic;
    using System.Text;
    using System.Windows.Forms;namespace OutlookAddin1
    {
        public static class OutlookTool
        {        public static void CreateTask(DataRow row)
            {
                // Create a new task item.
                Outlook.MAPIFolder tasksFolder = Globals.ThisApplication.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);
                Outlook.TaskItem item = (Outlook.TaskItem)tasksFolder.Items.Add(Outlook.OlItemType.olTaskItem);
                item.Subject = row["Subject"].ToString();
                item.Owner = row["Owner"].ToString();
                item.PercentComplete = int.Parse(row["PercentComplete"].ToString());
                item.Status = (Outlook.OlTaskStatus)int.Parse(row["Status"].ToString());            item.Save();
            }
            public static void CreateContact(DataRow row)
            {
                // Create a new contact item.
                Outlook.MAPIFolder contactFolder = Globals.ThisApplication.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
                Outlook.ContactItem item = (Outlook.ContactItem)contactFolder.Items.Add(Outlook.OlItemType.olContactItem);
                item.FirstName = row["firstName"].ToString();
                item.LastName = row["lastName"].ToString();
                item.Department = row["department"].ToString();
                item.JobTitle = row["jobTitle"].ToString();
                item.Email1Address = row["email"].ToString();            item.Save();
            }
            public static string GetContactsXML()
            {
                // Get all contacts
                Outlook.MAPIFolder contactsFolder = Globals.ThisApplication.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
                StringBuilder xml = new StringBuilder("<contacts>", 100);
                for(int i=1;i<=contactsFolder.Items.Count;i++)
                {
                    Outlook.ContactItem item = contactsFolder.Items[i] as Outlook.ContactItem;
                    xml.Append("<contact>");
                    xml.Append("<firstName>" + item.Subject + "</firstName>");
                    xml.Append("<lastName>" + item.LastName + "</lastName>");
                    xml.Append("<department>" + item.Department + "</department>");
                    xml.Append("<jobTitle>" + item.JobTitle + "</jobTitle>");
                    xml.Append("<email>" + item.Email1Address + "</email>");
                    xml.Append("</contact>");
                    if (i > 50)
                        break;
                }
                xml.Append("</contacts>");
                return xml.ToString();        }
            public static string GetTaskXML()
            {
                // Get all tasks
                Outlook.MAPIFolder tasksFolder = Globals.ThisApplication.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);
                StringBuilder xml = new StringBuilder("<tasks>", 100);
                foreach (Outlook.TaskItem item in tasksFolder.Items)
                {
                    xml.Append("<task>");
                    xml.Append("<subject>" + item.Subject + "</subject>");
                    xml.Append("<owner>" + item.Owner + "</owner>");
                    xml.Append("<percentComplete>" + item.PercentComplete.ToString() + "</percentComplete>");
                    xml.Append("<status>" + ((int)item.Status).ToString() + "</status>");
                    xml.Append("</task>");
                }
                xml.Append("</tasks>");
                return xml.ToString();
            }
            public static void CreateAppointmentInCalendar(DataRow row)
            {
                // Create a new appointment item in calendar.
                Outlook.MAPIFolder tasksFolder = Globals.ThisApplication.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
                Outlook.AppointmentItem appointmentitem = (Outlook.AppointmentItem)tasksFolder.Items.Add(Outlook.OlItemType.olAppointmentItem);
                appointmentitem.Subject = row["subject"].ToString();
                appointmentitem.Body = row["body"].ToString();
                appointmentitem.Start = DateTime.Parse(row["Start"].ToString());
                appointmentitem.End = DateTime.Parse(row["End"].ToString());
                appointmentitem.Save();
            }
            public static string GetAppointmentsXML()
            {
                Outlook.MAPIFolder appointmentFolder = Globals.ThisApplication.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
                StringBuilder xml =new StringBuilder( "<appointments>",100);
                foreach (Outlook.AppointmentItem item in appointmentFolder.Items)
                {
                    xml.Append("<appointment>");
                    xml.Append("<subject>" + item.Subject + "</subject>");
                    xml.Append("<body>" + item.Body + "</body>");
                    xml.Append("<start>" + item.Start.ToString() + "</start>");
                    xml.Append("<end>" + item.End.ToString() + "</end>");
                    xml.Append("</appointment>");
                }
                xml.Append("</appointments>");
                return xml.ToString();
            }
            private static ListView GetListView(string title, string[] cols)
            {
                ListView listView = new ListView();
                listView.Dock = DockStyle.Fill;
                listView.View = View.Details;
                foreach (string col in cols)
                {
                    listView.Columns.Add(col);
                }
                return listView;
            }
        }
    }
      

  2.   

    我前段时间做的一个关于OutLook的东西 发给你几个链接,很全面的。
    http://blog.csdn.net/liugy1126/archive/2009/05/11/4167956.aspx
    http://msdn.microsoft.com/en-us/library/cc513843.aspx
    http://msdn.microsoft.com/zh-cn/library/ms778202.aspx
    http://www.cnblogs.com/iCeSnaker/articles/43101.html
    http://msdn.microsoft.com/zh-cn/library/aa289167(VS.71).aspx
    http://www.codeguru.cn/windows/Microsoft-Outlook-Ojbect/overview.htm
    http://www.cnblogs.com/zyk/archive/2004/11/02/59707.html