[英]c#, Microsoft.Office.Interop.Outlook, non default-folder
I need a count, view, edit items of a non-default calendar, but I have a problem to access to it. 我需要计算,查看,编辑非默认日历的项目,但是访问它时遇到问题。
How to access to a non-default calendar in c# (for have a Outlook.MAPIFolder) ? 如何在C#中访问非默认日历(具有Outlook.MAPIFolder)? please
请
After create the new "Adhésion" calendar in "\\xxx@outlook.fr". 在“ \\ xxx@outlook.fr”中创建新的“Adhésion”日历之后。 I would like to access to it in c# app.
我想在C#应用程序中访问它。
Is it a correct way ? 这是正确的方法吗?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Outlook = Microsoft.Office.Interop.Outlook;
namespace ACC_adhérents
{
class Program
{
static void Main(string[] args)
{
Outlook.Application app = new Outlook.Application();
Outlook.NameSpace ns = app.GetNamespace("mapi");
ns.Logon("xxxx@outlook.fr", Missing.Value, true, true);
Outlook.MAPIFolder inboxFolder = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
Outlook.MAPIFolder parentFolder = inboxFolder.Parent;
Outlook.MAPIFolder adhesionFolder = parentFolder.Folders["Tâches - Adhésion"];
Console.WriteLine("Folder Name: {0}, EntryId: {1}", adhesionFolder.Name, adhesionFolder.EntryID);
Console.WriteLine("Num Items: {0}", adhesionFolder.Items.Count.ToString());
ns.Logoff();
}
}
}
If the folder is already opened in Outlook, start with the ns.Folders collection (returns top level folders of all stores in the profile) and drill down to the folder you want. 如果已在Outlook中打开该文件夹,请从ns.Folders集合开始(返回配置文件中所有商店的顶级文件夹),然后向下钻取到所需的文件夹。 You can also use the Namespace.Stores collection to get to the secondary store you want and then use Store.GetDefaultFolder (for the default folders) or Store.GetRootFolder to strat with the top fodler of the store.
您还可以使用Namespace.Stores集合转到所需的辅助存储,然后使用Store.GetDefaultFolder(用于默认文件夹)或Store.GetRootFolder来与商店的顶级存储设备分层。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.