【问题标题】:Loading items like calendar and contacts from public folder从公用文件夹加载日历和联系人等项目
【发布时间】:2015-08-26 22:16:25
【问题描述】:

我四处寻找从公用文件夹加载日历/联系人项目的方法。通过 Outlook,这很简单,您只需将其拖放到公用文件夹中即可。我已经到了访问日历的目的,但我不确定如何通过 C# 将其加载到 Outlook 中。

private void AddCalendar()
{
    Outlook._NameSpace session = null;
    Outlook.MAPIFolder publicFolders = null;
    OUtlook.MAPIFolder allPublicFolders = null;
    Outlook.MAPIFolder seCalendar = null;

    try
    {
        session = _thisApp.GetNamespace("MAPI");
        publicFolders = session.Folders["Public Folders"];
        allPublicFolders = publicFolders.Folders["All Public Folders"];
        seCalendar = allPublicFolders.Folders["SE Calendar"];
        // ????
        // profit
    }
    finally
    {
        //Release Items
    }
}

下面是我正在尝试做的图片。您通常只是从自己的日历开始,我正在尝试加载公用文件夹中的公司日历。

【问题讨论】:

    标签: c# outlook-addin


    【解决方案1】:

    遍历 MAPIFolder.Items 集合中的项目。在您的特定情况下,这些项目将是 AppointmentItem、ContactItem 和 DistListItem。

    Outlook.Items items = seCalendar.Items;
    for (int i = 1; i <= items.Count; i++)
    {
      object item = items[i];
      Outlook.AppointmentItem appt = item as Outlook.AppointmentItem;
      if (apt != null)
      {
         MessageBox.Show(appt.Subject);
         Marshal.ReleaseComObject(appt);
      }
      Marshal.ReleaseComObject(item);
    }
    

    【讨论】:

    • 我刚刚编辑了我的问题。如何将 AppointmentItems 加载到我的日历视图中,以便它像图像一样显示?
    猜你喜欢
    • 1970-01-01
    • 2017-06-30
    • 2014-05-03
    • 1970-01-01
    • 1970-01-01
    • 2012-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多