Access 获取共享文件夹会议的子文件夹 [英] Access Get subfolder of shared folder meetings

查看:49
本文介绍了Access 获取共享文件夹会议的子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的代码可以让我从共享的子日历中检索会议,但它不起作用.

I have the code below that should let me retrieve the meetings from a shared sub calendar, but it doesn't work.

如果我只尝试访问主共享日历,它可以完美运行,但不适用于子日历..

If I only try to access the main shared calendar it works perfect, but not for the sub calendars..

有人能指出我正确的方法吗?

could someone point me to the right way?

Public Sub getCalendarData(calendar_name As String, sDate As Date, eDate As Date, Optional recurItem As Boolean = True)
    On Error GoTo ErrorHandler

    Dim oOL As Outlook.Application
    Dim oNS As Outlook.Folder
    Dim oAppointments As Outlook.AppointmentItem
    Dim oAppointmentItem As Outlook.AppointmentItem
    Dim strFilter As String
    Dim ItemsCal As Outlook.Items
    Dim olFolder As Outlook.Folder
    Dim fldCalendar As Outlook.Folder
    Dim iCalendar As Integer
    Dim nmsNameSpace As Outlook.Namespace
    Dim objDummy As Outlook.MailItem
    Dim objRecip As Outlook.Recipient

    'Set objects

    Set oOL = CreateObject("Outlook.Application")
    Set nmsNameSpace = oOL.GetNamespace("MAPI")

    Set objDummy = oOL.CreateItem(olMailItem)

    Set objRecip = nmsNameSpace.CreateRecipient("shared calendar name")
    objRecip.Resolve

    'Set filter to grab items by date range
    strFilter = "[Start] >= " _
    & "'" & sDate & "'" _
    & " AND [End] <= " _
    & "'" & eDate & "'"

    With ItemsCal
        .Sort "[Start]"
        .IncludeRecurrences = recurItem
    End With

    If objRecip.Resolved Then
        On Error Resume Next
        Set fldCalendar = nmsNameSpace.GetSharedDefaultFolder(objRecip, olFolderCalendar).Folders("sub_calendar_name")

        If Not fldCalendar Is Nothing Then
            Set ItemsCal = fldCalendar.Items
            If Not ItemsCal Is Nothing Then
                For Each oAppointmentItem In ItemsCal.Restrict(strFilter)
                    Set objItem = oAppointmentItem
                    With oAppointmentItem
                        iCalendar = getSegmentIDByName(calendar_name)
                        meeting_id = insertAppointment(iCalendar, .Start, .End, scrubData(.Subject), scrubData(.Location), Format(.Start, "Long Time"), .duration, .Body)
                        Call GetAttendeeList(meeting_id, objItem, .Recipients)
                    End With
                Next
            End If
        End If
    End If

    'Garbage cleanup
    Set oAppointmentItem = Nothing
    Set oAppoinments = Nothing
    Set oNS = Nothing
    Set oOL = Nothing

Exit Sub
ErrorHandler:
    'MsgBox "Error: " & Err & " | " & Error(Err)
    'Whenever error occurs, skip to next
    Resume Next
End Sub

问题是 fldCalendar 总是返回 nothing 而我不知道出了什么问题..

The problem is that fldCalendar is always returning nothing and I don't know what is wrong..

谢谢!

推荐答案

请记住,在缓存模式下,当您从另一个邮箱访问默认文件夹时,您不会访问整个邮箱 - 文件夹(但不是它的子文件夹)缓存在您的主 OST 文件中.

Keep in mind that in the cached mode when you are accessing a default folder from another mailbox, you are not accessing the whole mailbox - the folder (but not its subfolders) is cached in your primary OST file.

您可以将整个邮箱添加为委托存储(Exchange 帐户属性对话框的高级选项卡),然后从 Store.RootFolder 深入到该文件夹​​(其中 Store 是从 Store.RootFoldercode>Namespace.Stores 集合).

You can add the whole mailbox as a delegate store (Advanced tab of the Exchange account properties dialog box) and then drill down to that folder from Store.RootFolder (where Store is retrieved from the Namespace.Stores collection).

如果使用 Redemption 是一个选项,则是 RDOSession.GetSharedDefaultFolder(或 RDOSession.GetSharedMailbox)返回一个活动文件夹(RDOFolder),而不是其缓存版本,因此您将能够访问子文件夹.

If using Redemption is an option, is version of RDOSession.GetSharedDefaultFolder (or RDOSession.GetSharedMailbox) returns a live folder (RDOFolder), not its cached version, so you will be able to access the subfolders.

这篇关于Access 获取共享文件夹会议的子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆