延迟Outlook 2010中的会议邀请 - vba


1

我正在尝试编写一个代码来安排会议邀请,并在以后的日期/时间自动延迟发送给参与者,即延迟发送会议邀请

下面是代码,但是我想在30分钟后发送邀请时发出错误。

错误行:

Application.Wait(Now + TimeValue(“06:30:00”))

真的很感谢这方面的帮助。非常感谢

Sub Book_meeting_room()


Dim olApp As Outlook.Application
Dim olApt As AppointmentItem

Set olApp = Outlook.Application                 'Creating Outlook Session
Set olApt = olApp.CreateItem(olAppointmentItem) 'Creating an Appointment

With olApt

.MeetingStatus = olMeeting                  'olAppointmentItem with Meeting status olMeeting
                                            'becomes a OL Meeting Item.
.Subject = "Room 1"                         'Subject
.Start = #11/20/2017 8:30:00 AM#            'Enter Date + Time here.
.Duration = 240                             'In Minutes
.Location = "Office"                        'Location of the meeting.
.Recipients.Add ("Margaret")                'Recipient Name, Alias, or any other Attribute.
.BusyStatus = olFree
.ReminderSet = True
.ReminderMinutesBeforeStart = 20

End With

Application.Wait (Now + TimeValue("06:30:00"))          'defer 06hrs and 30mins.
olApt.Send                             'Sending Mail.
Set olApt = Nothing

MsgBox "Invite Sent", vbInformation

End Sub

什么是错误消息?TIMEVALUE函数返回一个时间序列号。我不认为这是你想要的吗?
戴夫

它给出了调试错误..宏工作正常,直到Application.wait语法我正在寻找延迟交付会议邀请
Adsar

虽然这个问题在某些方面有所不同,但它也与您的其他问题相同:superuser.com/questions/1260042 / ...有几种方法可以解决这种情况:使用上一个问题的“编辑”按钮改变它并删除这个问题。将答案标记为在另一个问题上接受,以便可以将其关闭,或完全删除其他问题。不应该发生的事情是让您不接受或打开旧问题。
music2myear


我已经删除了上一个问题
格子2017年

Answers:


0

Application.Wait不适用于outlook你可以使用Doevent带定时器的Sleep函数或函数

使用Doevent是最好的选择,因为它可以让你在启动宏后继续工作,如果你过度使用它会发生问题:

Public Sub Pause(Seconds As Single)
Dim TimeEnd As Single
TimeEnd = Timer + Seconds
While Timer < TimeEnd
    DoEvents
Wend
End Sub 

在睡眠状态下,您需要声明该功能,并且在发送消息之前不再允许您继续工作。你声明它:

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

您的代码变为如下(您还可以注意.Display将使程序正常工作的其他其他问题)

Sub Book_meeting_room()

Dim olApp As Outlook.Application
Dim olApt As AppointmentItem

Set olApp = Outlook.Application                 'Creating Outlook Session
Set olApt = olApp.CreateItem(olAppointmentItem) 'Creating an Appointment

With olApt

.MeetingStatus = olMeeting                  'olAppointmentItem with Meeting status olMeeting
                                            'becomes a OL Meeting Item.
.Subject = "Room 1"                         'Subject
.Start = #11/20/2017 8:30:00 AM#            'Enter Date + Time here.
.Duration = 240                             'In Minutes
.Location = "Office"                        'Location of the meeting.
.Recipients.Add ("Margaret")                'Recipient Name, Alias, or any other Attribute.
.BusyStatus = olFree
.ReminderSet = True
.ReminderMinutesBeforeStart = 20
.Display

End With

Pause (23400) 'defer 06hrs and 30mins.
'Sleep (23400) 'also defer 06hrs and 30mins eventually

olApt.Send                             'Sending Mail.
Set olApt = Nothing

MsgBox "Invite Sent", vbInformation

End Sub
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.