我正在研究创建一个 Outlook 插件,我可以从“对话历史记录”文件夹中选择一个对话,然后单击一个将其保存到文件夹的按钮。是否有人对我如何选择对话历史文件夹并通过 C# 运行搜索以及选择对话有任何指示。
问问题
1190 次
1 回答
0
public static List<Outlook.MAPIFolder> GetFolders()
{
List<Outlook.MAPIFolder> _list = new List<Outlook.MAPIFolder>();
Outlook.MAPIFolder root = OutlookApplication.Session.DefaultStore.GetRootFolder();
foreach (Outlook.MAPIFolder folder in root.Folders)
{
_list.Add(folder);
}
return _list;
}
public static Outlook.MAPIFolder GetFolderByEntryId(string entryId)
{
List<Outlook.MAPIFolder> folders = GetFolders();
return folders.Where(x => x.EntryID == entryId).FirstOrDefault();
}
public static Outlook.MAPIFolder GetFolderByName(string folderName)
{
List<Outlook.MAPIFolder> folders = GetFolders();
return folders.Where(x => x.Name == folderName).FirstOrDefault();
}
和
public static List<Outlook.MailItem> GetSelectedItem()
{
List<Outlook.MailItem> _list = new List<Outlook.MailItem>();
Outlook.Selection outlookSelection = OutlookApplication.ActiveExplorer().Selection;
for (int i = 1; i < outlookSelection.Count; i++)
{
Outlook.MailItem mailItem = (Outlook.MailItem)outlookSelection[i];
_list.Add(mailItem);
}
return _list;
}
public static List<Outlook.MailItem> GetMailItems(string FolderName)
{
List<Outlook.MailItem> _list = new List<Outlook.MailItem>();
Outlook.MAPIFolder theFolder = OutlookApplication.Session.GetFolderFromID(GetFolderByName(FolderName).EntryID);
foreach (Object item in theFolder.Items)
{
Outlook.MailItem mailItem = (Outlook.MailItem)item;
if (mailItem != null)
{
_list.Add(mailItem);
}
}
return _list;
}
于 2012-05-08T13:29:51.557 回答