首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >检索多个电子邮件地址的空闲/繁忙时间

检索多个电子邮件地址的空闲/繁忙时间
EN

Stack Overflow用户
提问于 2013-06-20 06:19:02
回答 1查看 4.5K关注 0票数 7

我和3-4个“忙”的人安排会议。使用调度助手检索和更新可用时间可能很繁琐。

我正在尝试创建一个Excel宏(打开Outlook ),以便根据提供的电子邮件地址查看可用时间。

如果日期已知(已完成),此宏将创建会议。如果日期不知道,我需要打印的日期,每个人都是免费的电子表格。

所有用户都在同一台服务器上。

Sub GetFreeBusyInfo ()是我需要帮助的地方。

1.它可以打印单个可用性,但我需要整个组的免费/繁忙信息。

2.如何以"07/01/2013 3:00-4:00 PM EST“格式显示结果?

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
Option Explicit
Sub CheckAvail()
Dim myOutlook As Object
Dim myMeet As Object
Dim i As Long

'Create the Outlook Session
Set myOutlook = CreateObject("Outlook.Application")
'Create the AppointmentItem
Set myMeet = myOutlook.CreateItem(1)
myMeet.MeetingStatus = 1

i = 23
'Start at row 23
If Cells(i, 11) <> "" Then
    'Add Recipients
    Do Until Trim(Cells(i, 10).Value) = ""
       'Add all recipients
        myMeet.Recipients.Add Cells(i, 10)
        i = i + 1
    Loop

    i = 23
    myMeet.Start = Cells(i, 11).Value

    'Set the appointment properties
    myMeet.Subject = Cells(i, 12).Value
    myMeet.Location = Cells(i, 13).Value
    myMeet.Duration = Cells(i, 14).Value
    myMeet.ReminderMinutesBeforeStart = 88
    myMeet.BusyStatus = 2
    myMeet.Body = Cells(i, 15).Value
    myMeet.Save
    myMeet.Display

Else
   Call GetFreeBusyInfo

End If

End Sub

Public Sub GetFreeBusyInfo()
Dim myOutlook As Object
Dim myMeet As Object

Dim myNameSpace As Object
Dim myRecipient As Object
Dim myFBInfo As String, k As Long, j As Long, i As Long

'Create the Outlook Session
Set myOutlook = CreateObject("Outlook.Application")
Set myMeet = myOutlook.CreateItem(1)
myMeet.MeetingStatus = 1
i = 23
Do Until Trim(Cells(i, 10).Value) = ""
    'Add all recipients
    myMeet.Recipients.Add Cells(i, 10)
    i = i + 1
Loop    

Set myNameSpace = myOutlook.GetNamespace("MAPI")
k = 1
i = 23
Do Until Trim(Cells(i, 10).Value) = ""
    k = k + 1
    Set myRecipient = myNameSpace.CreateRecipient(Cells(i, 10).Value)
    On Error GoTo ErrorHandler
    j = 2
    Cells(k, j) = Cells(i, 10).Value
    Do Until Trim(Cells(i, 10).Value) = ""
        myFBInfo = myRecipient.FreeBusy(#7/1/2013#, 60)
        j = j + 1
        Cells(k, j) = myFBInfo
        i = i + 1
    Loop
Loop
myMeet.Close
ErrorHandler:
    MsgBox "Cannot access the information. "
End Sub
EN

回答 1

Stack Overflow用户

发布于 2016-02-26 07:10:43

我对类似的问题很感兴趣,所以我编写了一些代码,解决了根据会议信息为所有收件人找到一个相互可用的时间段的问题。

我不确定您到底想要什么作为输出,所以现在它只是将所有可用的时间写到最上面的行上。代码很容易调整,以显示单个收件人的所有时隙和空闲/繁忙状态。

守则的整体结构如下:

首先,收集所有收件人的空闲/忙碌状态(就像您所做的那样)。这是一个巨大的数字串(0/1/2/3),表示给定时间段的可用性(在给定的持续时间间隔内)。从给定的日期开始(今天),您可以将分钟加起来,以便为每个时间段获得一个合适的DateTime。

将所有可用信息存储在数组集合中。也许这是一个更好的方法,但我希望它是简单明了的。

遍历每个时隙,找出每个人的可用性数组加起来为0 (0 =免费)的时间。在这种情况下,打印出这个特定的时隙,然后转到下一个时隙。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
Option Explicit

Sub CheckAvail()
Dim myOutlook As Object
Dim myMeet As Object
Dim i As Long

'Create the Outlook Session
Set myOutlook = CreateObject("Outlook.Application")
'Create the AppointmentItem
Set myMeet = myOutlook.CreateItem(1)
myMeet.MeetingStatus = 1

i = 23
'Start at row 23
If Cells(i, 11) <> "" Then
    'Add Recipients
    Do Until Trim(Cells(i, 10).Value) = ""
       'Add all recipients
        myMeet.Recipients.Add Cells(i, 10)
        i = i + 1
    Loop

    i = 23
    myMeet.Start = Cells(i, 11).Value

    'Set the appointment properties
    myMeet.Subject = Cells(i, 12).Value
    myMeet.Location = Cells(i, 13).Value
    myMeet.Duration = Cells(i, 14).Value
    myMeet.ReminderMinutesBeforeStart = 88
    myMeet.BusyStatus = 2
    myMeet.Body = Cells(i, 15).Value
    myMeet.Save
    myMeet.Display

Else
   Call GetFreeBusyInfo

End If

End Sub

Public Sub GetFreeBusyInfo()
Dim myOutlook As Object
Dim myMeet As Object

Dim myNameSpace As Object
Dim myRecipient As Object
Dim i As Integer, totalMinutesElapsed As Long
Dim myMeetingDuration As Integer, intFreeBusy As Integer, intTimeslot As Integer, intEarliestHour As Integer, intLatestHour As Integer
Dim dtStartTime As Date, dtFinishTime As Date
Dim myFBInfo As String
Dim doHeaders As Boolean
Dim intFreeBusyCode As Integer

Dim recipStartRow As Integer
recipStartRow = 23 ' defined by question/asker

'Create the Outlook Session
Set myOutlook = CreateObject("Outlook.Application")
Set myMeet = myOutlook.CreateItem(1)
myMeet.MeetingStatus = 1

myMeetingDuration = CInt(Cells(recipStartRow, 14).Value) ' same as above - need duration

'Add all recipients
i = 0
Do Until Trim(Cells(recipStartRow + i, 10).Value) = ""
    myMeet.Recipients.Add Cells(recipStartRow + i, 10)
    i = i + 1
Loop

Set myNameSpace = myOutlook.GetNamespace("MAPI")

' uncomment to have all possible timeslots write out
Dim debugRow As Integer, debugCol As Integer
debugRow = 2
debugCol = 2

' --> define the general 'working hours' here
' (anything timeslots that start before this period or end after this period will be ignored)
intEarliestHour = 8 '8am
intLatestHour = 17 '5pm

' set up structure to store free/busy info
Dim colAvailability As Collection, colRecipients As Collection
Dim strRecipientName As String
Dim arrayAvailability(1 To 1000) As Integer
Dim arrayStartDates(1 To 1000) As Date
Set colAvailability = New Collection
Set colRecipients = New Collection

' loop through each recipient (same as above)
doHeaders = True
i = 0
Do Until Trim(Cells(recipStartRow + i, 10).Value) = ""

    intTimeslot = 1

    strRecipientName = Cells(recipStartRow + i, 10).Value
    Set myRecipient = myNameSpace.CreateRecipient(strRecipientName)

    'Cells(debugRow + i, debugCol) = strRecipientName
    colRecipients.Add strRecipientName ' collections respect order of addition
    myFBInfo = myRecipient.FreeBusy(Date, myMeetingDuration, True)

    ' parse FB info string - stored as digits that represent Free/Busy constants, starting at midnight, in given time intervals
    For intFreeBusy = 1 To Len(myFBInfo)

        totalMinutesElapsed = CLng(intFreeBusy - 1) * myMeetingDuration

        dtStartTime = DateAdd("n", totalMinutesElapsed, Date)
        dtFinishTime = DateAdd("n", (totalMinutesElapsed + myMeetingDuration), Date)

        If Hour(dtStartTime) < intEarliestHour Or Hour(dtFinishTime) > intLatestHour Then

            ' skip this potential time slot
        Else

            intFreeBusyCode = CInt(Mid(myFBInfo, intFreeBusy, 1))

            ' Cells(debugRow + i, debugCol + intTimeslot) = GetFreeBusyStatus(intFreeBusyCode)
            arrayAvailability(intTimeslot) = intFreeBusyCode


            If doHeaders = True Then
                ' Cells(debugRow - 1, debugCol + intTimeslot) = dtStartTime
                arrayStartDates(intTimeslot) = dtStartTime
            End If

            intTimeslot = intTimeslot + 1

        End If

    Next intFreeBusy

    colAvailability.Add arrayAvailability ' save each recipients array of availability codes

    doHeaders = False
    i = i + 1
Loop

' search through each array to find times where everyone is available
For intTimeslot = 1 To 1000
    ' stop when we run out of time slots
    If arrayStartDates(intTimeslot) = #12:00:00 AM# Then
        Exit For
    End If

    dtStartTime = arrayStartDates(intTimeslot)

    ' loop through each meeting recipient at that time slot
    intFreeBusy = 0
    For i = 1 To colRecipients.Count
        intFreeBusy = intFreeBusy + colAvailability.Item(i)(intTimeslot)
    Next i

    If intFreeBusy = 0 Then ' everyone is free!
        debugCol = debugCol + 1
        Cells(debugRow - 1, debugCol).Value = dtStartTime


    End If

Next intTimeslot


'myMeet.Close


End Sub

Function GetFreeBusyStatus(code As Integer) As String

' https://msdn.microsoft.com/en-us/library/office/ff864234.aspx
' 0 = free
' 1 = tentative
' 2 = busy
' 3 = out of office
' 4 = "working elsewhere"

If code = 0 Then
    GetFreeBusyStatus = "Free"
ElseIf code = 1 Then
    GetFreeBusyStatus = "Tentative"
ElseIf code = 2 Then
    GetFreeBusyStatus = "Busy"
ElseIf code = 3 Then
    GetFreeBusyStatus = "Out"
ElseIf code = 4 Then
    GetFreeBusyStatus = "WFH"
Else
    GetFreeBusyStatus = "??"
End If

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

https://stackoverflow.com/questions/17216080

复制
相关文章
LeetCode - 独特的电子邮件地址
LeetCode第929题,难度简单。三个半月之前的题目了,最近只能够选择周末做题,然后一次性把一周的题目都写完,然后每天回家定时发送
晓痴
2019/08/13
9810
929. 独特的电子邮件地址
每个 有效电子邮件地址 都由一个 本地名 和一个 域名 组成,以 ‘@’ 符号分隔。除小写字母之外,电子邮件地址还可以含有一个或多个 ‘.’ 或 ‘+’ 。
Regan Yue
2023/03/25
7760
929. 独特的电子邮件地址
LeetCode 929. 独特的电子邮件地址
例如,在 alice@leetcode.com中, alice 是本地名称,而 leetcode.com 是域名。
Michael阿明
2020/07/13
7940
如何使用 Python 验证电子邮件地址
在本文中,我将向大家展示如何使用名为 verify-email 的 Python 库构建你自己的电子邮件验证工具。
海拥
2023/02/27
2.7K0
如何使用 Python 验证电子邮件地址
LeetCode 759. 员工空闲时间(排序)
返回表示 所有 员工的 共同,正数长度的空闲时间 的有限时间段的列表,同样需要排好序。
Michael阿明
2021/02/19
8950
2455 繁忙的都市
题目描述 Description        城市C是一个非常繁忙的大都市,城市中的道路十分的拥挤,于是市长决定对其中的道路进行改造。城市C的道路是这样分布的:城市中有n个交叉路口,有些交叉路口之间有道路相连,两个交叉路口之间最多有一条道路相连接。这些道路是双向的,且把所有的交叉路口直接或间接的连接起来了。每条道路都有一个分值,分值越小表示这个道路越繁忙,越需要进行改造。但是市政府的资金有限,市长希望进行改造的道路越少越好,于是他提出下面的要求: 1.  改造的那些道路能够把所有的交叉路口直接或间接的连通
attack
2018/04/12
6190
设置SSH空闲超时退出时间【Linux】
2,将ClientAliveInterval 设置为300到900,即5-15分钟,将ClientAliveCountMax设置为0-3之间。
sinnoo
2020/11/13
11.5K0
【TKE】设置 Websocket 空闲连接断开时间
通过 Ingress-nginx(TKE 组件) 代理 ws 连接成功后, 空闲连接会在默认 60s 后 断开,有时业务中想要配置空闲连接更长时间再断开。
Jokey
2023/09/22
2.2K0
用 Volcano 填补私有集群的空闲时间
在私有 Kubernetes 场景下,因为硬件规模是一定的,不太会随着业务高峰低谷进行裁撤,因此缩减下来的服务资源并不能带来成本上的优势,如果在闲时~挖挖矿~跑跑 AI 大数据什么的是不是可以贴补一下家用呢?Volcano 值得一试。
崔秀龙
2021/09/29
1.2K0
Flink SQL空闲状态保留时间实现原理
如果要列举Flink SQL新手有可能犯的错误,笔者认为其中之一就是忘记设置空闲状态保留时间导致状态爆炸。
王知无-import_bigdata
2021/07/12
1.4K0
Flink SQL空闲状态保留时间实现原理
如何用现有电子邮件地址注册 Windows Live ID
最近遇到一些朋友问起是否能用其他的电子邮件地址作为MSN的帐号,答案是肯定的——微软官方说:您可以使用任何电子邮件提供商提供的现有电子邮件地址注册 Windows Live ID 凭据。然后使用这些凭据登录任何 Windows Live ID 站点。这里的“凭据”指的就是 Windows Live ID 帐号。以下介绍 Windows Live ID 的注册形式和方法。其中第二种形式就是使用已有电子邮件地址作为MSN帐号。
Enjoy233
2019/03/05
2.1K0
1083: [SCOI2005]繁忙的都市
1083: [SCOI2005]繁忙的都市 Time Limit: 10 Sec  Memory Limit: 162 MB Submit: 1319  Solved: 878 [Submit][Status] Description 城市C是一个非常繁忙的大都市,城市中的道路十分的拥挤,于是市长决定对其中的道路进行改造。城市C的道路是这样分布的:城市中有n个交叉路口,有些交叉路口之间有道路相连,两个交叉路口之间最多有一条道路相连接。这些道路是双向的,且把所有的交叉路口直接或间接的连接起来了。每条道路都有一
HansBug
2018/04/10
6260
Flink 1.9 - SQL 空闲状态保留时间实现原理
最近在做 Flink SQL 方面的研究,我们有这样一个场景,就是按照天来实时统计截止到当前时刻的某些指标值。Flink SQL 中会使用状态来存储统计后的结果值,但是有一个问题就是,其实统计的指标值也只有当天才会用到,后续其实很少会用到这些数据。由于统计的粒度非常的细,所以这里 Flink SQL 任务中的状态就会非常大,导致 HDFS 上面的存储占用过大。Flink SQL 中支持状态空闲时间的设置,如果某个 Key 的状态在一定 时间没有被更新, Flink 会自动清理该状态。本文结合 Flink 1.9 SQL 中的代码,尝试研究该原理的实现流程。
LakeShen
2022/06/23
9020
Flink 1.9  - SQL 空闲状态保留时间实现原理
acwing-1142. 繁忙的都市[通俗易懂]
城市C是一个非常繁忙的大都市,城市中的道路十分的拥挤,于是市长决定对其中的道路进行改造。
全栈程序员站长
2022/09/22
3600
27 亿电子邮件地址外泄!ElasticSearch数据库再次中招
数据泄露事件近年来时有发生,哪怕是大体量的Facebook也未能幸免。可以说数据泄露无论是对用户还是对企业来讲都造成了一定的损失和影响。针对频频发生的数据泄露事件,不少企业都加大网络安全建设力度,也起到了一定的成效,但数据泄露事件依旧屡禁不止。
用户6543014
2019/12/17
8510
27 亿电子邮件地址外泄!ElasticSearch数据库再次中招
Netty空闲检测之写空闲
在之前的文章,我们介绍了Netty空闲检测之读空闲,以及为了介绍此篇文章,我们也特意写了一篇关于写操作的概括文章.读者对于Netty如何进行写操作也有了一个大概的认识了,接下来我们说一下,对于如何检测
书唐瑞
2022/06/02
6580
Netty空闲检测之写空闲
Netty空闲检测之读空闲
客户端与服务端通信的时候,服务端如何感知到客户端下线.客户端可以每4秒向服务端发送一个数据,服务端每5秒进行空闲检测.如果服务端没有读取到数据,则认为客户端已下线.(实际业务中并不会这么处理,我们这里只是为了描述场景)
书唐瑞
2022/06/02
7250
Netty空闲检测之读空闲
空闲时间请大家不要接私活,要提升自己!
现在社会,有很多人都在利用个人时间兼职赚钱,程序员俗称“接私活”,其他行业称作兼职,比如下了班出去跑滴滴,周末兼职抢单送外卖等等,都是普通人很常见的兼职方式。
JAVA高级架构开发
2018/10/06
1K0
程序员怎么利用空闲时间充电提升自己?
初级Java程序员成长为进阶程序员需要不断的积累和辅助,对于新手来说并非遥不可及,只要遵循一定的原则,比如,先养成几个通往成功的好的习惯,程序员怎么利用空闲时间充电提升自己呢?本文为大家带来一位前辈的习惯养成经验,供大家参考,如果受用,请把他们记在心里,贴在桌子上。
Java知音
2018/10/21
1.2K0
【算法千题案例】每日一练LeetCode打卡——108.独特的电子邮件地址
每个 有效电子邮件地址 都由一个 本地名 和一个 域名 组成,以 '@'符号分隔。除小写字母之外,电子邮件地址还可以含有一个或多个 '.' 或'+' 。
呆呆敲代码的小Y
2022/01/25
8200
【算法千题案例】每日一练LeetCode打卡——108.独特的电子邮件地址

相似问题

使用python从microsoft检索空闲/繁忙状态

24

django日历-空闲/繁忙/可用

26

找到下一个空闲时间给定的繁忙时间阵列

10

空闲资源繁忙时测试UI

23

基于空闲/繁忙呼叫的图像转换

10
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文