Autoaccept a Meeting Request using Rules

An interesting problem came up in the Microsoft public newsgroups this week. Richard posts:

We have a specific user requirement to auto accept meeting requests only from some selected organizers, but I don't see any choice in Rule Wizard for meeting requests. Does anyone have an idea, please?

Since there is not an action to respond to meeting requests, you'll need to use a script to accept it. Outlook MVP Michal Bednarz offers this script, which you need to add to ThisOutlookSession before creating the rule.

This was tested in Outlook 2007 and should work in any version which supports the Run a Script action.

How to use

Open Outlook's VBA editor (Alt+F11), expand Microsoft Office Outlook Objects then double click on ThisOutlookSession. Type or paste the code into the module, then create the rule with the 'run script' Action and select this script

To decline a meeting, replace olMeetingAccepted with olMeetingDeclined:

Set oResponse = oAppt.Respond(olMeetingDeclined, True)

To Save with no response sent

To accept the meeting and add it to your calendar automatically, without sending a response, Christopher changed the last part of the code to:

Sub AutoAcceptMeetingsWed(oRequest As MeetingItem)
If oRequest.MessageClass <> "IPM.Schedule.Meeting.Request" Then
Exit Sub
End If
Dim oAppt As AppointmentItem
Set oAppt = oRequest.GetAssociatedAppointment(True)
dayWed = WeekdayName(Weekday(oAppt.Start))
If dayWed = "Wednesday" Then
Dim oResponse
Set oResponse = oAppt.Respond(olMeetingAccepted, True)
oResponse.Send
End If
End Sub

Check Free/Busy before accepting

Steve wanted to know how to decline if there was a conflict. For this we need to check Free/Busy. Checking the Free/Busy is actually fairly easy and the code we need is at Recipient.FreeBusy Method.

Set yourself as a Recipient, using your email address, display name, or alias:

Set myAcct = Session.CreateRecipient("alias@slipstick.com")

Then get your Free/Busy string:

myFB = myAcct.FreeBusy(oAppt.Start, 5, False)

You need a date to check, and we'll use the appointment start date. The Free/Busy string begins at midnight on this date.

The next value is how many minutes are in each Free/Busy "period" represented by the myFB string. After much trial and error, I've decided that 5 minutes is probably the best value, since it's the smallest time period displayed on the calendar.

The final value is True or False (if you leave it blank, it's False). False tells Outlook to either return 0 for Free (and Working elsewhere in Outlook 2013) and 1 for "not free". True returns values specific to the Show time as setting.

Next, you need to know how many time periods are between midnight and the appointment time (there are 288 5 minutes periods each day):

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

Use that value to create a string of the periods the appointment covers. If you want to build in some downtime between appointments, subtract from i before calculating ( i - 2 gives 10 min between appointments) and add the same value to the duration calculation.

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

test = Mid(myFB, i-2, (oAppt.Duration / 5)+2) starts 2 periods before the start time, or in my example, leaves 10 min between the last appointment and this one.

Finally, we use InStr to look for a match within the substring that covers our appointment period. If the string contains a 1, the appointment should be declined:

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

To help you understand the code (and check my calculations), I left my Debug.Print code in. Open the Immediate windows in the VB Editor using Ctrl+G or select it from the View menu to see the results. Those 0, 1, and 2's each represent a 5 minute block of time beginning at 12:00 AM on that date.

If you want to check for specific values or consider tentative appointments as Free, you can change If InStr(1, test, "1") Then to use different values. Use If InStr(1, test, "2") or InStr(1, test, "3") Then to check for Busy and Out of Office.

Free/Busy

Value

Free

0

Tentative

1

Busy

2

Out of Office

3

Working Elsewhere (Outlook 2013)

0

Macro Security

Macro security needs to be set on Notify for all macros. Using Enable All macros is a poor choice as it is often reset to the signed macros only option by security software or updates. If you prefer, you can sign the macro using SelfCert and set security to Signed macros only. If you choose to use SelfCert, sign the macro after you are finished editing it as it will need to be re-signed after each edit.

To access macro security dialog, go to File, Options, Trust Center in Outlook 2010. Use Tools, Macros, Security menu in Outlook 2007 and older. When security is set to Notify, you will be asked if you want to run the macro each time you start Outlook.

Related Posts:

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Comments

Thank you so much for posting this code. I'm wondering if there is somethig similar for "not sending a response". So, when I've added the rules you have above with the code, the meeting notice accepts, but it pops open a response email where I could type a response. I have to click send on that email for it to be added to my calendar. can that step be elimanted with a rule??

I've used this code and it does add it to my calendar but it only pulls up the email to send the response without actually sending it to the meeting requestor. Any suggestions for how to reply using the accept meeting template?

It *worked* in 2010/32. After I rebooted, the script no longer seems to run? It's there, it's selectable from the rules wizard, but doesn't appear to be executed. Added a breakpoint, and that never triggers.

I set this up for meetings with Subject lines that look like vacation notices (I get a lot) but discovered it has a problem when the meeting request does not require a response. In order for it to process without errors pulling up Visual Basic for debugging, I adjusted it to conditionally handling the oResponse:

If oAppt.ResponseRequested Then
Set oResponse = oAppt.Respond(olMeetingAccepted, True)
oResponse.Close (olSave)
Else 'no object to close if response was not requested
Call oAppt.Respond(olMeetingAccepted, True) 'meeting is still accepted to calendar
End If

Same issue. Ended up running "selfcert.exe" which comes with the office package, create a certificate, and then choosing Tools - Digital signature in the VBA editor, choosing the newly created certificate as a signature. Upon restart, outlook asks if I want to trust it, I answer "trust all from..." and the macro has been running fine ever since.

I implemented the code above, along with the "Save with no response sent " and "Delete from the Inbox once processed" portions. Unfortunately, when the script runs, I get a security popup (the one where I have to wait five seconds to click yes). I have signed the script using my CAC digital certificate and also set the macro security settings to medium. Anyone have any ideas?

Is there a way to Send a response without having the invitation pop up when received? I want the organizer to be able to see who has accepted without the recipient having to type in a message. In other words, the equivalent of "Send the response now." when accepting meetings... but automatic.

I want the meeting organizer to be able to see who has accepted the invitation. Adding oResponse.Close (olSave) works perfectly but does not alow the organizer to see that it was accepted. So I do want a "response" to be sent to the meeting organizer in a sense... but I dont want the user to get a popup where they have to accept/enter a response manually.

This is awesome... I just had ~140 meeting requests from the same person in my inbox to set up multiple monthly meetings for the whole year and this accepted and processed them w/in 45 seconds... saved me an hr! Thanks a lot!!! Very cool stuff.

There might be, but I can't think of a way offhand - I'll ask my dev expert friends. If its a problem, we recommend creating busy appointments for the off-time so people won't try to schedule that period. If the problem is with working in a different time zone and people forget that, use it in the subject, something like "I'm in Eastern TZ and work 9AM-5PM"

it is gr8 help for me. tks.
is there any micro which declines meeting request
outlooke should accept 4 meeting request of starting at same time.but should decline if 5th meeting for same time. it is for shared calendar where multiple people works on same calendar.

So when a request is sent to a user(meeting room) it should get auto accepted and a confirmation mail sould be sent depending uppon the availability . If its not available meaning the user (the meeting room) is blocked by some other user for that particular time, it should show a not available or the next available slots .

However, I do have one question on a modification: I'm trying to auto-accept all-day event invitations, not meeting requests (it's how my company handles employee late/out/leaving early notifications). I'm fairly sure Outlook treats meetings and all-day events as different forms (creating a new meeting creates "Untitled - Meeting," where creating a new all-day event creates "Untitled - Event"), and the set-up you described doesn't work on these event invitations. I checked out the available forms, but couldn't find anything that sounded like the all-day event invitation form. Do you have any insight on how I can solve this problem? Thanks again!

I think they use the same form - test it by inviting yourself to an all day event then check the message class in the inbox - turn off the reading pane to drop to a one line view then right click on the row of field names and choose Field Chooser. Under one of the All [forms] lists, find meeting class and drag it to the row of field names.

Diane,
I followed the steps above but am apparently missing something in the process. When I go set up my rule and choose 'uses the form name form' I have no forms to choose from. I am running Outlook 2007 with Exchange 2003.

One of the Director's here wants to Auto-Decline Meeting invitations from specific users. I know how to set up this type of rule, but need your script. I would like the meeting to be automatically declined, and then I will set the rule up to send an automatic reply to the user. Will the script you have posted (I've changed it to "DECLINE") work? I am going to test it now, but here's my code:

Sub AutoDeclineMeetings(oRequest As MeetingItem)

If oRequest.MessageClass "IPM.Schedule.Meeting.Request" Then
Exit Sub
End If

This all worked for me. Thanks so much for the notes.
However, I want to be able to display the calendar on a wide screen for general information. Although the appointments are "accepted," placed on the calendar and no response is sent -- which is exactly what I wanted it to do -- the appointments stay in the lighter color and are hard to read. Does anyone know how to change the appearance of an appointment without having to go to each one and formally accept? I just need them to be easier to read.

This is the only calendar in your view? Once accepted, they should look like any other meeting or appointment. However, if you have two calendars overlaid, the appointments on the "bottom" calendar are lighter.

I've been fighting with this for quite a while now and figured I'd just out and ask. I'm trying to configure this script to auto-decline appointments sent from a specific address. I've got the rule working and it appears to decline the appointments and delete the messages, but I keep getting my calendar filled up with they shaded versions of the appointments. I'd like the script to auto-decline and NOT send a response to the requestor.

Here is my script:
Sub AutoDeclineMeetings (oRequest As MeetingItem)

If oRequest.MessageClass "IPM.Schedule.Meeting.Request" Then
Exit Sub
End If

If you want to decline without sending a response, use a rule to delete meetings requests from the addresses. That should remove the tentative copy from the calendar. (Although it doesn't here - possibly because I have my test mailbox open in 3 different Outlooks.)

This is great. I am using this script but it seems to be giving error with Outlook 2010. Is there a version for this for Outlook 64 ? Is there a way to have a rule like this on Exchange Server to say accept meeting from a particular address. Say CEO sends out an invite and it should be auto accepted by all employees.

The original script works great. I made a slight modification to have an automatic reply sent to the user who was scheduling the meeting. I use my solution as a virtual machine running Outlook 2010 for managing a Conference Room Calendar. Here is the full script:

Sub AutoAcceptMeetings(oRequest As MeetingItem)

If oRequest.MessageClass "IPM.Schedule.Meeting.Request" Then
Exit Sub
End If

Many thanks for your post, we have an issue here we use MS CRM Dynamics2011 with Outlook 2010 on our client systems.
CRM is on premises hosted.
Issue is that client uses a shared calender for all appoitments, and we create appoitments from CRM which goes to the person who is responsible to attend the meeting.

But as for other it needs to appear in the shared calendar as well so that no one else book the same slot for another appoitment. For this i have created a Outlook rule for a specific subject to clone the appoitment in the shared calendar.
Bot the only way i am able to make it work is when the person accepts the appoitment and send the reply to the generator of that appoitment.
For this i am trying to use you script at the individual Outlook so that any appoitment with a apecific subject are auto accepted.

you script is working fine for any appoitments created from Outlook but not for appoitments created from CRM.
Is that a form diffrence between the both?

I am using Outlook 2010 with MS Exchange server. I am trying to automatically accept meeting requests from a specific individual, not send a response, and have it remove the event from my inbox after accepting. I have the following script code called from a rule for all items from the specific user but nothing happens when I get events from them. Is this something to do with using exchange server or the way the meeting requests are coming from the sender?

Sub AutoAcceptMeetings(oRequest As MeetingItem)

If oRequest.MessageClass "IPM.Schedule.Meeting.Request" Then
Exit Sub
End If

This has been great as it shows me how to set up a rule to accept a meeting and send a response, but I also want to assign it to a category and show the time as free. Can I add those two things to the rule or to the macro? If the macro, what would the VBA code look like?

While you could insert the With-End With block right after the Set oAppt line, the category is added but the busy status isn't changed until after you send the response, so it needs to be after the response.

I have a question. I don't want to run a script using the client but is there a way that when an appointment gets placed say on a Resource that something runs to send it out to a distribution list and automatically accepts the appointment, places it on the calendar and deletes it from the users Inbox.

Assuming a mailbox, server side rules (you need to long into the mailbox to set it up). If a public folder, use Folder Assistant. At least for the send to a DL - accepting / processing it can only be done by the recipient.

This looks very cool but I was wondering if this could also be executed via a macro toolbar button instead of a rule. I have this case where I want to look at the meeting invite before I "decline without answer". This sub does not show in the available "macros".

I would like to have meetings accepted. However, I don't like the reminders attached to the invitation. Have you an idea how the script at the top need to be modified to have automatically accepted the meeting invitation, and at the same time removing automatically any reminder for said meeting?
Thank you very much in advance for your comments!

-------------------------------------------
The script should in Outlook:
-accept the meetings automatically
-avoiding to send a feedback
-removing any reminder to avoid being disturbed all the time by the popping-up of the reminders

Hi Diane,
many thanks for this great idea!
Unfortunatly it does not work and I have no glue why not.

I created the rule - no Problem. But when I execute the rules the VBA code is not called. I checked it with a break point. I also checked the "first" steps of the rules. Instead calling the code I copied the meeting requests to anohter folder - works fine.
In consequence there must be a problem with the macro call out of the rule.

I have problem with meeting request responses. i have requested my colleague to attend a meeting through a shared calender , when he accepts it, there should be a response mail in shared mailbox, but i'm not receiving any mail from him and also i have tried with many users like this but "no" response mail after they have accepted it. please suggest me what could be the issue with this?

Hello! I have the same question as another person above. I receive automatically generated calendar requests based on my training schedule. I automatically accept them using the script above with no problem. If my class is cancelled, I get an auto-generated cancellation. I'd like to create a rule with a script that will automatically remove those cancelled items (My rules are excuted based on the subject line). Will someone share a modified script to auto remove cancelled items from my calendar? I'm assuming I would use the "MeetingCancellation" form. Thanks!

Diane, I applied the script and the rule in it's entirety works great. I have a monkey wrench to throw into this though. What if I'd like to keep this rule in effect but, I'd also like updates on meeting requests (changed times, dates, ect.) to come through the users inbox and alert them. Any ideas?
Brandon

Hi, as part of the acceptance, I would like to add a 15 min appt 'block' of time to myself to avoid back to back meetings...I'm struggling to find the 'end time' of the meeting I am accepting and use it to set the start time of my 'block' appt. Any suggestions greatly appreciated.

if you are using an autoaccept rule, try something like this to create the companion appointment. I haven't tested it yet, but it looks like it is correct.
Sub AutoAcceptMeetings(oRequest As MeetingItem)

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

Hi all I could use some help. I'm trying to auto decline and not send a response to the sender. I also don't want it to show up on my calendar, but for some reason it still shows up on my calendar and gives me a reminder. I don't know what I'm doing wrong, here is my code.

Sub AutoDeclineMeetings(oRequest As MeetingItem)

If oRequest.MessageClass "IPM.Schedule.Meeting.Request" Then
Exit Sub
End If

No it doesn't work, it still adds it to my calendar, even though it does not accept the event. I don't want it to show up on my calendar at all because it still pops up with a reminder even if I don't accept the event.

I got it to work, looks like you have to close outlook and open it back up (if you don't close outlook it does not save the code) then accept the marco as a trusted publisher again. here is the code I used.

Sub AutoDeclineMeetings(oRequest As MeetingItem)

If oRequest.MessageClass "IPM.Schedule.Meeting.Request" Then
Exit Sub
End If

You'll need to check free busy - maybe something like this
Dim myAcct As Outlook.Recipient
Dim myFB As String
Set myAcct = myol.CreateRecipient("my alias")
' False returns 1 for busy, oof, or tentative, 0 for free
' true returns 1,2,3 or 0. So you could accept if free or tentative (1)
myFB = myAcct.FreeBusy(oAppt.Start, oAppt.duration, False)
if myFB <> 0 Then
'accept
The code is untested so it might not be exactly right - basically, you need to get the start date and time and duration and check it against your free busy. You could search the calendar on the date and time and look for busy appt, but i think using free/busy is more efficient.

Set myRecipient = ns.CreateRecipient("XX@in.APAC.com")
myRecipient.Resolve
If myRecipient.Resolved Then

Sub AutoProcessMeetingRequest(oRequest As MeetingItem)
' bail if this isn't a meeting request
If oRequest.MessageClass "IPM.Schedule.Meeting.Request" Then Exit Sub
Dim oAppt As AppointmentItem
Set oAppt = oRequest.GetAssociatedAppointment(True)
Dim declinedReasons As String
declinedReasons = ""
If (oAppt.Location = "") Then
declinedReasons = declinedReasons & " * No location specified." & vbCrLf
End If
If (HasConflicts(oAppt)) Then
declinedReasons = declinedReasons & " * It conflicts with an existing appointment." & vbCrLf
End If
If (DateTime.DateDiff("h", DateTime.Now, oAppt.Start) < 24) Then
declinedReasons = declinedReasons & " * The meeting's start time is too close to the current time. " & vbCrLf
End If
Dim oResponse As MeetingItem
If (declinedReasons = "") Then
Set oResponse = oAppt.Respond(olMeetingAccepted, True)
oResponse.Body = _
" Please collect the key from sekr place Near and make the entry in the meeting room register. "
Else
Set oResponse = oAppt.Respond(olMeetingDeclined, True)
oResponse.Body = _
"This meeting request has been automatically declined for the following reasons:" & vbCrLf & _
declinedReasons
End If
oResponse.Send
oRequest.Delete
End Sub
Function HasConflicts(oAppt As AppointmentItem) As Boolean
Dim oCalendarFolder As Folder
Set oCalendarFolder = ThisOutlookSession.Session.GetDefaultFolder(olFolderCalendar)
Dim apptItem As AppointmentItem
For Each apptItem In oCalendarFolder.Items
If ((apptItem.BusyStatus olFree) And (oAppt apptItem)) Then
If (apptItem.Start oAppt.Start) Then
HasConflicts = True
Exit Function
End If
End If
End If
Next
HasConflicts = False
End Function
End If
End Sub

can you Help me with the code correction and also i want to do the same with Multiple Mailbox

I had a quick question. I was using the free/busy code and found that it was calculating the value of i to be 55. The time periods are in 5 minute blocks and my appointment is for 11:00 AM. The means there are 132 5 minute periods before the start time, and it kept displaying 55. I researched some more on it and found that there are actually 288 5 minute periods in a day. I change the multiplication factor on the "i =" from 120 to 288 and it now works perfectly (288 x 5)/60 = 24 hours. Did I miss something because I swear the code worked fine with 120 before?

I swear it worked with 120 before too (and didn't recheck it today) - it's been so long since i did it that I forget why i decided on 120 (600 minutes/10 hours) since it's clearly not how many periods are in a 24 hour day - unless I was using working hours, but that is not what I said in the text.

I followed your instructions for creating a Auto Decline Meetings macro, digitally signed it, and created the rule exactly as you suggested, but when I try to enable it, I get a message stating that the rule has been deactivated, that it could be because some of the parameters are not supported. Any idea? I am running MS Win-7 & MS Office Outlook Pro Plus 2010.

Select a meeting request in your inbox and run this - you'll get two message boxes then the decline meeting message displays on screen. It works fine here, so if it doesn't work there, then macros aren't enabled.

Actually, there is an improvement. With this script, the meeting request is automatically accepted and created in the agenda. However, the requestor does not receive the notification. This is not really a problem since I use this rule for syncing my own agenda at customer site with the prof. one, but I'd like to know what's the problem.

Sub AutoAcceptMeetings(oRequest As MeetingItem)

If oRequest.MessageClass "IPM.Schedule.Meeting.Request" Then
Exit Sub
End If

Just one small anomaly - I tried it with the original code quoted (before the Chris amendment) so am aware that when the script runs, it auto accepts in the calendar but then automatically opens a new email ready to send the response to the sender. I have then used the amendment provided by Chris to not send a response. However, it does create a response but puts it automatically into my Drafts folder. I'm using Outlook 2013.

Can I stop the response being created as a draft email, so all it literally does is auto add the appointment to my calendar and nothing else?

The code says to close and save but I don't recall getting drafts when I tested it. I'll retest it - if you use an imap account it could be because of some issues with drafts where they aren't properly deleted when the message is closed.

I have outlook 2013 and use rules to move emails from my inbox to personal folders. Out of the blue recently when I received a calendar invite that went to my personall folder per my rules, when I accepted the invitation it would not show up on my default outlook calendar and instead showed up on another calendar outlook created that is associated with the personal folder.

Prior to this issue first occurring about a month ago, it worked perfectly (i.e. It put all appointments on my default calendar when I accepted them). I have talked to my help desk folks and they tell me the only answer is to turn off my rules. That's seems crazy to me. Can you help? Thanks very much.

You can add an exception to the rules to look for message type so it skips meeting requests. Have you always had a calendar folder in the pst file? If there is no calendar, the meeting should go on the default calendar but if the pst has a calendar folder, it can go on that calendar - it's not supposed to when you use Exchange server though.

If you always had the calendar folder, it's possible an update changed the behavior.