当前位置: 动力学知识库 > 问答 > 编程问答 >

vba - Outlook macro to auto accept/auto tentative accept

问题描述:

I'm trying to make a macro for Outlook that runs when I receive a meeting request, and depending on if I have a meeting at that time, accept the request or tentatively accept. I've got the rule set up and working fine, it runs the vba as far as I know, but the below code isn't working. I can't find the issue with it...

Sub AcceptDecline(oRequest As MeetingItem)

If oRequest.MessageClass <> "IPM.Schedule.Meeting.Request" Then

Exit Sub 'if this messageclass isn't a meeting request

End If

Dim oAppt As AppointmentItem

Set oAppt = oRequest.GetAssociatedAppointment(True)

Dim myAcct As Outlook.Recipient

Dim myFB As String

Set myAcct = Session.CreateRecipient("[email protected]")

myFB = myAcct.FreeBusy(oAppt.Start, 5, False) 'gets the free or busy status of my calendar

Dim oResponse

Dim i As Long

Dim test As String

i = (TimeValue(oAppt.Start) * 288)

test = Mid(myFB, i - 2, (oAppt.Duration / 5) + 2)

If InStr(1, test, "1") Then

Set oResponse = oAppt.Respond(olMeetingTentative, True)

oResponse.Display

oResponse.Send

Else

Set oResponse = oAppt.Respond(olMeetingAccepted, True)

oResponse.Display

oResponse.Send

End If

End Sub

分享给朋友:
您可能感兴趣的文章:
随机阅读: