用C#导出outlook里的联系人 ?? 怎样导出outlook里面的联系人信息 本地的 和服务器的 能不能提供下源代码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 取服务器数据需要涉及到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; } }} 我前段时间做的一个关于OutLook的东西 发给你几个链接,很全面的。http://blog.csdn.net/liugy1126/archive/2009/05/11/4167956.aspxhttp://msdn.microsoft.com/en-us/library/cc513843.aspxhttp://msdn.microsoft.com/zh-cn/library/ms778202.aspxhttp://www.cnblogs.com/iCeSnaker/articles/43101.htmlhttp://msdn.microsoft.com/zh-cn/library/aa289167(VS.71).aspxhttp://www.codeguru.cn/windows/Microsoft-Outlook-Ojbect/overview.htmhttp://www.cnblogs.com/zyk/archive/2004/11/02/59707.html 后台生成的行和列的显示与隐藏 .net 中怎样实现在线人数的统计和在线会员的信息显示 Nhibernate中级联表中的字段怎么赋值啊? 新手的弱 FormatDateTime 问题!! 关于自定义控件使用的问题 问一个较白的问题。 Microsoft Visual Studio .NET 2003与Microsoft Visual Studio .NET 2002??? 请问如何调用外部程序 请教一个自定义控件的问题 tooltip问题!! 发个新种子 没有语言基础适合学习C#吗?
以前做的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;
}
}
}
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