首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用VBA验证两个outlook会议之间是否存在冲突

使用VBA验证两个outlook会议之间是否存在冲突
EN

Stack Overflow用户
提问于 2022-05-02 07:47:58
回答 1查看 95关注 0票数 0

我目前正在为outlook开发一个宏,以创建特定日期的会议。

我的宏可以创建、修改、删除会议。

当我创建一个会议时,我想检查会议之间是否有冲突。

我尝试过使用AppointmentItem.Conflicts属性,但是我无法获得任何好的结果。

谢谢你的帮助。

D

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-05-02 08:02:36

您可以使用Recipient.FreeBusy方法来返回收件人的空闲/繁忙信息。下面的VBA示例返回一串空闲/繁忙信息,每个小时有一个字符(完全格式)。

代码语言:javascript
复制
Set myRecipient = myNameSpace.CreateRecipient("Nate Sun") 
myFBInfo = myRecipient.FreeBusy(#02/05/2022#, 60, True)

要获取当前用户的信息,可以使用NameSpace.CurrentUser属性,该属性将当前登录用户作为收件人对象返回,因此可以对其调用FreeBusy方法。

注意,如果使用Exchange帐户,您可能会发现ExchangeUser.GetFreeBusy方法很有用。它返回一个字符串,表示从开始日期起30天内的ExchangeUser可用性,从指定日期的午夜开始。

代码语言:javascript
复制
Sub GetManagerOpenInterval() 
 Dim oManager As ExchangeUser 
 Dim oCurrentUser As ExchangeUser 
 Dim FreeBusy As String 
 Dim BusySlot As Long 
 Dim DateBusySlot As Date 
 Dim i As Long 
 Const SlotLength = 60 
 'Get ExchangeUser for CurrentUser 
 If Application.Session.CurrentUser.AddressEntry.Type = "EX" Then 
 Set oCurrentUser = _ 
 Application.Session.CurrentUser.AddressEntry.GetExchangeUser 
 'Get Manager 
 Set oManager = oManager.GetExchangeUserManager 
 If oManager Is Nothing Then 
 Exit Sub 
 End If 
 FreeBusy = oManager.GetFreeBusy(Now, SlotLength) 
 For i = 1 To Len(FreeBusy) 
 If CLng(Mid(FreeBusy, i, 1)) = 0 Then 
 'get the number of minutes into the day for free interval 
 BusySlot = (i - 1) * SlotLength 
 'get an actual date/time 
 DateBusySlot = DateAdd("n", BusySlot, Date) 
 'To refine this function, substitute actual 
 'workdays and working hours in date/time comparison 
 If TimeValue(DateBusySlot) >= TimeValue(#8:00:00 AM#) And _ 
 TimeValue(DateBusySlot) <= TimeValue(#5:00:00 PM#) And _ 
 Not (Weekday(DateBusySlot) = vbSaturday Or _ 
 Weekday(DateBusySlot) = vbSunday) Then 
 Debug.Print oManager.name & " first open interval:" & _ 
 vbCrLf & _ 
 Format$(DateBusySlot, "dddd, mmm d yyyy hh:mm AMPM") 
 Exit For 
 End If 
 End If 
 Next 
 End If 
End Sub

此外,您也可以尝试使所有会议在一个特定的间隔内开始或结束。Find/FindNextRestrict方法可以帮助完成这些任务。在以下文章中可以了解更多关于这些问题的内容:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72083728

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档