微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 Access VBA 从其他人的日历中删除约会

如何解决使用 Access VBA 从其他人的日历中删除约会

我有在 3 个技术同事日历中创建约会的代码,我需要代码来在取消特定课程时也删除这些约会。

将他们添加到新约会的代码如下:

If vbYes = MsgBox("Send Calendar Appointments?",vbYesNo) Then

Dim outMail As Outlook.AppointmentItem
Set outMail = Outlook.CreateItem(olAppointmentItem)
outMail.Subject = "Lab Booking - " & FullName & " - for date " & Forms!frmlabSession_edit!BookingDate
outMail.Mileage = Me.LabBooking_ID
outMail.Location = Forms!frmlabSession_edit!frm_qryLabsBookedPerBooking_subform!RoomNo
outMail.MeetingStatus = olMeeting
outMail.Start = BookingDate & " " & TimeFrom
outMail.End = BookingDate & " " & Timeto
outMail.ReminderMinutesBeforeStart = 21600
outMail.requiredAttendees = "Person1@tees.ac.uk; Person2@tees.ac.uk; Person3@tees.ac.uk" & Me.txtcclist
outMail.Body = "You have received this notification with a 15 days countdown to cover periods of leave when you may not have received initial notification." & Chr$(13) & _
Chr$(13) & Me.Notes
outMail.Attachments.Add FileName
outMail.Send
Set outMail = nothing
End If

我有用于根据主题删除约会的代码,但我不知道如何添加收件人 - 其他日历用户 - 它只会在 我的 日历中将其删除片刻。这是用于从我的日历中删除约会的代码

Dim objOutlook As outlook.application
Dim objNamespace As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objAppointment As Outlook.AppointmentItem
Dim lngDeletedAppointements As Long
Dim strSubject As String
Dim strLocation As String
Dim dteStartDate As Date

'******************************** Set Criteria for DELETION here ********************************
strSubject = "Lab Booking - " & FullName & " - for date " & Forms!frmlabSession_edit!BookingDate
strLocation = Forms!frmlabSession_edit!frm_qryLabsBookedPerBooking_subform!RoomNo
dteStartDate = BookingDate
'************************************************************************************************

Set objOutlook = outlook.application
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderCalendar)

For Each objAppointment In objFolder.Items
If objAppointment.Subject = strSubject And objAppointment.Location = strLocation And _
objAppointment.Start > dteStartDate Then
objAppointment.Delete
lngDeletedAppointements = lngDeletedAppointements + 1
End If
Next

MsgBox lngDeletedAppointements & " appointment(s) DELETED.",vbinformation,"DETETE Appointments"

我不确定如何在代码中声明或说明与会者日历以从中删除项目,就像顶部代码首先将他们发送到的方式一样。有人知道我会怎么做吗?我确实有删除他们日历的权限,可以进入他们的日历并删除约会,所以应该不是权限问题。

解决方法

您可以使用以下操作序列来取消会议并通知与会者:

AppointmentItem.MeetingStatus = olMeetingCanceled
AppointmentItem.Save
AppointmentItem.Send
AppointmentItem.Delete

只需设置会议取消状态,即 - 已安排的会议已取消。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。