Outlook 日历发送和接收
Outlook calendars send and receive
有没有办法以编程方式将 Outlook 本地共享日历与其 Exchange 版本同步?
我试过 Namespace.SendAndReceive() 但它似乎不影响日历...
有什么我想念的,或者是不可能的吗?
我想执行 "send" 从我的本地共享日历文件夹到他的服务器文件夹。
(我知道可以通过取消选中 "Download shared calendar" 直接在服务器版本上工作,如图 here 但我不能这样做)
编辑:
为什么我要尝试强制同步?
在我的加载项中,用户在共享日历中创建新约会,然后启动一个功能,该功能向使用 EWS 的脚本发出 HTTP 请求以获取此交换日历。但是由于没有发送新的约会,与 EWS 通信的脚本没有得到新的约会。
我发现 Send/Receive 中的 "update folder" 按钮将文件夹发送到交换服务器,但是查看 folder 对象我找不到如何以编程方式执行此操作...
我终于找到了一种将 Outlook 应用程序的本地共享日历与 Exchange 服务器版本同步的方法(实际上它做了 "send")。
下面的 VB.NET 代码以编程方式打开每个共享日历,然后模拟单击 "update calendar" 按钮。
Dim app As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim objExpl As Outlook.Explorer
Dim recip As Outlook.Recipient
Dim olPane As Outlook.NavigationPane
Dim olModule As Outlook.NavigationModule
Dim olGroup As Outlook.NavigationGroup
Dim navFoldersCount As Integer
ns = app.GetNamespace("MAPI")
objExpl = app.ActiveExplorer
For k = 1 To ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar).Folders.Count
Try
'Try catch allows to exclude non-shared calendars to work only with share ones
recip = ns.CreateRecipient(ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar).Folders.Item(k).Name)
recip.Resolve()
If recip.Resolved Then
objExpl.CurrentFolder = ns.GetSharedDefaultFolder(recip, Outlook.OlDefaultFolders.olFolderCalendar)
'accessing to the shared calendars creates their "Calendar - xxx@xxx.xxx" clone.
If Not objExpl Is Nothing Then
'Simulate the click on "UpdateFolder button
objExpl.CommandBars.ExecuteMso("UpdateFolder")
End If
End If
Catch
End Try
Next
olPane = ns.Application.ActiveExplorer.NavigationPane
olModule = olPane.Modules.GetNavigationModule(Outlook.OlNavigationModuleType.olModuleCalendar)
olGroup = olModule.NavigationGroups.GetDefaultNavigationGroup(Outlook.OlGroupType.olPeopleFoldersGroup)
'Removing calendar clones from the navigation pane
navFoldersCount = olGroup.NavigationFolders.Count
For i = navFoldersCount To 1 Step -1
If (olGroup.NavigationFolders.Item(i).DisplayName.Contains("Calendar - ")) Then
olGroup.NavigationFolders.Remove(olGroup.NavigationFolders.Item(i))
End If
Next
有没有办法以编程方式将 Outlook 本地共享日历与其 Exchange 版本同步?
我试过 Namespace.SendAndReceive() 但它似乎不影响日历...
有什么我想念的,或者是不可能的吗?
我想执行 "send" 从我的本地共享日历文件夹到他的服务器文件夹。
(我知道可以通过取消选中 "Download shared calendar" 直接在服务器版本上工作,如图 here 但我不能这样做)
编辑: 为什么我要尝试强制同步?
在我的加载项中,用户在共享日历中创建新约会,然后启动一个功能,该功能向使用 EWS 的脚本发出 HTTP 请求以获取此交换日历。但是由于没有发送新的约会,与 EWS 通信的脚本没有得到新的约会。
我发现 Send/Receive 中的 "update folder" 按钮将文件夹发送到交换服务器,但是查看 folder 对象我找不到如何以编程方式执行此操作...
我终于找到了一种将 Outlook 应用程序的本地共享日历与 Exchange 服务器版本同步的方法(实际上它做了 "send")。
下面的 VB.NET 代码以编程方式打开每个共享日历,然后模拟单击 "update calendar" 按钮。
Dim app As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim objExpl As Outlook.Explorer
Dim recip As Outlook.Recipient
Dim olPane As Outlook.NavigationPane
Dim olModule As Outlook.NavigationModule
Dim olGroup As Outlook.NavigationGroup
Dim navFoldersCount As Integer
ns = app.GetNamespace("MAPI")
objExpl = app.ActiveExplorer
For k = 1 To ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar).Folders.Count
Try
'Try catch allows to exclude non-shared calendars to work only with share ones
recip = ns.CreateRecipient(ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar).Folders.Item(k).Name)
recip.Resolve()
If recip.Resolved Then
objExpl.CurrentFolder = ns.GetSharedDefaultFolder(recip, Outlook.OlDefaultFolders.olFolderCalendar)
'accessing to the shared calendars creates their "Calendar - xxx@xxx.xxx" clone.
If Not objExpl Is Nothing Then
'Simulate the click on "UpdateFolder button
objExpl.CommandBars.ExecuteMso("UpdateFolder")
End If
End If
Catch
End Try
Next
olPane = ns.Application.ActiveExplorer.NavigationPane
olModule = olPane.Modules.GetNavigationModule(Outlook.OlNavigationModuleType.olModuleCalendar)
olGroup = olModule.NavigationGroups.GetDefaultNavigationGroup(Outlook.OlGroupType.olPeopleFoldersGroup)
'Removing calendar clones from the navigation pane
navFoldersCount = olGroup.NavigationFolders.Count
For i = navFoldersCount To 1 Step -1
If (olGroup.NavigationFolders.Item(i).DisplayName.Contains("Calendar - ")) Then
olGroup.NavigationFolders.Remove(olGroup.NavigationFolders.Item(i))
End If
Next