简体   繁体   English

C#,Microsoft.Office.Interop.Outlook,非默认文件夹

[英]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.

相关问题 Microsoft.Office.Interop.Outlook - Microsoft.Office.Interop.Outlook 使用Microsoft.Office.Interop.Outlook连接到Outlook的稳定性C#表单 - Stability C# Forms connected to Outlook using Microsoft.Office.Interop.Outlook Outlook API或使用Microsoft.Office.Interop.Outlook-在C#中获取会议室/位置 - Outlook APIs OR Using Microsoft.Office.Interop.Outlook - Getting meeting room/location in C# 使用 Microsoft.Office.Interop.Outlook C# 在客户端打开 Outlook 2013 新约会窗口 - Open Outlook 2013 New Appointment window at Client side with Microsoft.Office.Interop.Outlook C# 如何使用Microsoft.Office.Interop.Outlook库通过C#读取.eml文件? - How Can I use Microsoft.Office.Interop.Outlook library to read .eml file using C#? 如何在使用 Microsoft.Office.Interop.Outlook 从 C# 发送邮件时删除“代表” - How to remove "on behalf of " while sending mail from C# using Microsoft.Office.Interop.Outlook 从Windows Service启动C#Microsoft.Office.Interop.Outlook - C# Microsoft.Office.Interop.Outlook launch from Windows Service Microsoft.Office.Interop.Outlook发布内存 - Microsoft.Office.Interop.Outlook Release Memory Microsoft.Office.Interop.Outlook GetFolderFromID - Microsoft.Office.Interop.Outlook GetFolderFromID 如何使用 Microsoft.Office.Interop.Outlook 创建默认配置文件并启动 Outlook 客户端 (GUI) - How to create a default profile and launch outlook client(GUI) using Microsoft.Office.Interop.Outlook
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM