Autoaccept a Meeting Request using Rules

Last reviewed on June 21, 2014   —  128 comments

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?

Create a ruleOf course I have an idea. Begin with a rule using the conditions "from people or distribution list" and "uses the specified form", choosing the Meeting Request form under Application forms.

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.

The Code

Sub AutoAcceptMeetings(oRequest As MeetingItem)

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

Dim oAppt As AppointmentItem
Set oAppt = oRequest.GetAssociatedAppointment(True)

Dim oResponse
 Set oResponse = oAppt.Respond(olMeetingAccepted, True)
 oResponse.Display
End Sub

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:

Dim oResponse

Set oResponse = oAppt.Respond(olMeetingAccepted, True)
oResponse.Close (olSave)

End Sub

To Delete from the Inbox once processed

Add the following before End Sub:

oRequest.Delete

Apply rule to meetings scheduled for a specific day of the week

This edit uses the WeekDayName function to get the day of the week and automatically process the meeting. Use the full weekday name in the string.

dayWed = WeekdayName(Weekday(oAppt.Start))
If dayWed = "Wednesday" Then

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.

Debug.print results in the Immediate window

Sub CheckFreeBusy(oRequest As MeetingItem)
If oRequest.MessageClass <> "IPM.Schedule.Meeting.Request" Then
  Exit Sub
End If
 
Dim oAppt As AppointmentItem
Set oAppt = oRequest.GetAssociatedAppointment(True)

Dim myAcct As Outlook.Recipient
Dim myFB As String

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

Debug.Print oAppt.Duration
Debug.Print "Time: " & TimeValue(oAppt.Start)
Debug.Print "periods before appt: " & TimeValue(oAppt.Start) * 288
Debug.Print oAppt.Start

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

Debug.Print myFB

Dim oResponse
Dim i As Long
Dim test As String

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

Debug.Print "String to check: " & test

If InStr(1, test, "1") Then
 Set oResponse = oAppt.Respond(olMeetingDeclined, True)
 oResponse.Display
 
 Else
  Set oResponse = oAppt.Respond(olMeetingAccepted, True)
 oResponse.Display
End If
End Sub

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.

Complete steps for using the VBA Editor and SelfCert are at How to use the VBA Editor

About Diane Poremsky

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.

Please post long or more complicated questions at Outlook forums by Slipstick.com.

128 responses to “Autoaccept a Meeting Request using Rules”

  1. Sadie

    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??

    1. Sarah

      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?

    2. Diane Poremsky

      Change oResponse.Display to oResponse.Send to automatically send it. Display is great during testing so you can see what is happening, then switch to Send to fully automate it.

  2. LT

    This doesn't seem to work with Outlook 2010. Any suggestion?

  3. Diane Poremsky

    It works here in 32-bit Outlook 2010. Do you get any error messages?

    1. Christopher Pharo Gl

      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.

    2. Christopher Pharo Gl

      Seems like scripts run from the rules have a tendency to wreak havoc with the VBAProject.OTM-file. Deleted it, and now the script runs fine.

    3. Diane Poremsky

      That's usually because of macro security. you need it set on medium (allow all to run, with warning)

  4. Christopher Pharo Gl

    Change the last part of the code to:

    Set oResponse = oAppt.Respond(olMeetingAccepted, True)

    oResponse.Close (olSave)

    And the appointment will be saved, no response will be sent.

    I also added

    oRequest.Delete

    at the bottom to remove it from my inbox once processed.

    This is Outlook 2010 32bit.

    1. Jamie Kitson

      oRequest.Delete didn't work for me so I just added "delete" to the rule.

    2. David

      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

  5. Ron

    Also had a problem - it worked once, then never again. Exchange 2003 with OL2010 on terminal server. I am looking for some app to do this now - hoping codetwo may do it.

    1. Diane Poremsky

      What is your macro security set on?

  6. Ron

    I tried the setting to enable all macro, but it made no difference.

    1. Christopher Pharo Gl

      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.

  7. David

    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?

    I am running WINXP SP3 and Outlook 2003 SP3 in a WIN2003 domain environment with Exchange 2003 servers.

    1. David

      Forgot to add-

      I also tried signing with a regular code signing certificate and that didn't work.

      I tried the code below and it seemed to break the auto accept code above.

      --------

      OlSecurityManager.DisableOOMWarnings = True

      On Error Goto Finally

      Sub AutoAcceptMeetings(oRequest As MeetingItem)

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

      Exit Sub

      End If

      Dim oAppt As AppointmentItem

      Set oAppt = oRequest.GetAssociatedAppointment(True)

      Dim oResponse

      Set oResponse = oAppt.Respond(olMeetingAccepted, True)

      oResponse.Close (olSave)

      End Sub

      Finally:

      OlSecurityManager.DisableOOMWarnings = False

      -------

    2. Diane Poremsky

      Is the cert set as a trusted cert? Or try using selfcert (and then trust yourself.)

    3. David

      The CAC cert is trusted through a CA and the code signing cert is a selfcert and then I trusted myself.

  8. David Hall

    What if there is a meeting already scheduled for the same time of the new request? Is there any way of addressing a scheduling conflict?

    1. Diane Poremsky

      Not within the script. You can do it if you have Outlook configured to not accept if a conflict but it will accept (or decline) everything - the rule won't do you any good.

  9. Chris

    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.

    Thanks! :)

    1. Diane Poremsky

      Christopher posted that you need to add oResponse.Close (olSave) before the End Sub to accept without sending a response.

  10. Chris

    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.

    1. Diane Poremsky

      Hmm. It should work - the response is received, but not processed. I'll try and figure out why - I'm not sure if its my settings or the script. (None of my responses ae processing.)

  11. Me

    is there a way to accept canceled meetings? delete the if they were canceled?

  12. Laza_C

    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.

  13. Henrique

    A pop up shows up and I have to wait 5 seconds to be able to click Ok. I think David had the same issue, couldn't identify any solution in the forum. Any ideas ?

    1. Diane Poremsky

      Can you send me a screenshot? (to diane at slipstick ) This shouldn't bring up the one dialog that brings up a delay. Also, which version of Outlook?

  14. Eric

    I was only able to open VB editor once (and was interrupted half way through), but now the ALT+F11 to open it no longer works. Any thoughts ?

    1. Diane Poremsky

      Close Outlook and try renaming VbaProject.OTM file - in Windows 7, you can paste %appdata%\microsoft\outlook into the address bar of windows explorer to jump to it.

  15. vijay

    Is there a way to extend this and decline for meetings scheduled from say 10pm to 6am?

    1. Diane Poremsky

      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"

  16. vin

    I got a problem with sending, which is the last step. Basically I get the window of the decline message but it is not being sent automatically, I need to click on the "Send" button.

    Does anybody know how to fix this ?

    1. Diane Poremsky

      Try changing .Display in the last line to .Save. (.Display is great when you need to verify it is working.)

  17. picki

    Is there any chance to make the calender items "private" right with auto-acceptance?

    1. Diane Poremsky

      possibly... you need to set the sensitivity... I have not tested this (and won't have time until this afternoon) - but something like this might work:

      Set oAppt = oRequest.GetAssociatedAppointment(True)
      Set oAppt.Sensitivity = olPrivate

  18. sharad

    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.

  19. arul patrick

    excited ! gr8 wrk yar :)

    In my case i am trying to make one of my meeting room as a user .

    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 .

    Guys can some one of u help me ?

  20. picki

    Thanks for the quick reply. The "private setting" via

    Set oAppt.Sensitivity = olPrivate

    didn't work. Any idea on how to fix it?

  21. Diane Poremsky

    It works but it needs to be saved, oh and you don't need Set.

    Dim oAppt As AppointmentItem
    Set oAppt = oRequest.GetAssociatedAppointment(True)
    oAppt.Sensitivity = olPrivate

    Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingAccepted, True)
    oResponse.Display
    oAppt.Save

  22. Christin

    Excellent! Thanks so much for this.

    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!

    1. Diane Poremsky

      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.

  23. Mr Brinson

    When I use the "Save with no response sent," It automatically saves the message response to my drafts folder. What can I do to fix this?

  24. Haik

    Thanks, this was super useful

  25. Scott Redding

    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.

    1. Diane Poremsky

      Technically, you don't need that condition as the code checks for meetings too:
      If oRequest.MessageClass <> "IPM.Schedule.Meeting.Request" Then
      Exit Sub
      End If

      I use it so the rule doesn't run on every message.

      But I believe you are looking at Personal forms in the left dropdown. Choose Application forms.
      Screenshot

  26. Scott Redding

    There are no forms to choose from on either option (Personal forms or Application forms) Is there something special I need to do when saving the script?

    1. Diane Poremsky

      No, nothing special you need to do - those are outlook's standard forms so you should see them. Are you using Outlook in online mode to your exchange server? That might be a factor.

      As I mentioned earlier, you don't really need that condition anyway...

  27. Scott Redding

    Exchange Server.

  28. Christine Lisi

    Office 2010/32 bit

    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

    Dim oAppt As AppointmentItem
    Set oAppt = oRequest.GetAssociatedAppointment(True)

    Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingDeclined, True)
    oResponse.Display
    End Sub

    1. Diane Poremsky

      Yes, it should work. If you need to send a generic autoreply, you add a few more lines to this script and have the one script do it all.

  29. Christine Lisi

    I would like to add a generic text response to the sender via the code. Can you help?

    1. Diane Poremsky

      This is untested and may need (will probably need) tweaked to work - but you can add something like this to the code to autoreply to the meeting organizer.

      Dim oMsg As MailItem
      Set oMsg = Application.CreateItem(olMailItem)

      oMsg.To = oRequest.organizer 'need the correct field name
      oMsg.Subject = "Sorry, I must decline " & oRequest.Subject
      oMsg.Body = "reply text goes here"
      oMsg.Send

  30. Christine Lisi

    It's not working. Sorry for the multiple posts but it will not allow me to EDIT my original post. Thanks!

  31. Tracey Brown

    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.

    Thanks!

    1. Diane Poremsky

      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.

  32. Steve Ahlers

    I changed the following:

    oResponse.Display to oResponse.Send

    Otherwise the Accepted reply was not being sent.

  33. Amanda Marie

    This is awesome! Just one question, what do I do if I want to accept the meeting request, but want the time to appear as free on my calendar?

    1. Diane Poremsky

      You need to set the busystatus and save it -

      oAppt.BusyStatus = olFree
      oAppt.Save

  34. Tim Sherburn

    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

    Dim oAppt As AppointmentItem
    Set oAppt = oRequest.GetAssociatedAppointment (True)

    Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingDeclined, True)
    oResponse.Close (olSave)
    End Sub

    1. Diane Poremsky

      The tentative appt should be removed when the meeting is declined.

      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.)

      oAppt.Delete should also remove the tentative if decline doesn't.

  35. picki

    If an auto-accepted meeting is cancelled: Is there any chance to process the cancellation in a way that the calendar entries are deleted?

  36. Jonathan

    I had an issue where 'responses' were kept in my Drafts (didn't want responses going out in this case). So I changed the code in the oResponse section as follows:

    Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingAccepted, True)
    ' oResponse.Close (olSave)
    oResponse.Delete
    oRequest.Delete
    End Sub

  37. Christine Lisi

    This feed is very complicated, so I can't tell who is responding to what. I'm basically trying to do the same thing that Tim Sherburn is, which:

    1. Auto Decline Meeting from specific user(s)
    2. Send the Decline message back to the meeting organizer with a generic message
    3. No meeting should show on my calendar; dimmed or otherwise

    Can someone help with my script? This is what I have based on responses above but I know the oMsg section is incorrect and I'm confused as to what to put on the oResponse line. Here is what I have:

    Sub AutoDeclineMeetings(oRequest As MeetingItem)

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

    Dim oAppt As AppointmentItem
    Set oAppt = oRequest.GetAssociatedAppointment(True)

    Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingDeclined, True)
    oResponse.Send
    oRequest.Delete

    Dim oMsg As MailItem
    Set oMsg = Application.CreateItem(olMailItem)
    oMsg.To = oRequest.organizer ‘need the correct field name
    oMsg.Subject = “Sorry, I must decline ” & oRequest.Subject
    oMsg.Body = “reply text goes here”
    oMsg.Send

    End Sub

  38. Riaz

    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.

    1. Diane Poremsky

      It works with 2010 64-bit, also 2013. It's more likely a typo or something that got messed up in the copy and paste. To use something like this on exchange, you'd need to use event sinks.

  39. Steve Ahlers

    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

    Dim oAppt As AppointmentItem
    Set oAppt = oRequest.GetAssociatedAppointment(True)

    Dim oResponse

    Set oResponse = oAppt.Respond(olMeetingAccepted, True)
    oResponse.Send
    oRequest.Delete

    End Sub

  40. Mark Fern

    I'm trying to set the appointment to free, but it's not working.
    Diane Poremsky May 15, 2012 at 2:14 pm | Permalink
    You need to set the busystatus and save it –

    oAppt.BusyStatus = olFree
    oAppt.Save

    This exact code did not work, so I've tried variations. Any suggestions would be helpful. Here's my code:

    Sub AutoAcceptMeetings(oRequest As MeetingItem)

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

    Dim oAppt As AppointmentItem
    Set oAppt = oRequest.GetAssociatedAppointment(True)
    Set oAppt.BusyStatus = olFree
    oAppt.Save

    Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingAccepted, True)
    oResponse.Display

    End Sub

  41. Rahul Thakur

    Hi Steve,

    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?

    It will be a great help if you have any ideas to resolve the issue.

    Regards
    Rahul

    1. Diane Poremsky

      Use a list view and add the message class field to the view - what message class does the CRM generated appointments use?

  42. Rahul Thakur

    AppointmentRequest Class

  43. Jeff B.

    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

    Dim oAppt As AppointmentItem
    Set oAppt = oRequest.GetAssociatedAppointment(True)

    Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingAccepted, True)
    oResponse.Close (olSave)
    oResponse.Delete
    oRequest.Delete
    End Sub

    1. Diane Poremsky

      You have this set up in a rule? That is all you need, well, along with not configuring Outlook to autoaccept meetings.

  44. Jeff B.

    When I closed Outlook it asked if I wanted to save the VBA project (even though I had been saving. After I launched Outlook again the script/rule worked. Thank you for all the great ideas and help.

    1. Diane Poremsky

      Asking to save doesn't necessarily mean anything - the littlest thing could cause it to ask to Save changes. The only thing I can think is that it was macro security and restarting it fixed it.

  45. Sara

    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?

    1. Diane Poremsky

      You can add any field supported by appointments.
      The change would look like this -

      oResponse.Save

      With oAppt
      .Categories = "New Appt"
      .BusyStatus = olFree
      .Save
      End With
      End Sub

      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.

  46. Shelly Spradley

    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.

    1. Diane Poremsky

      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.

  47. Pierre

    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".

  48. Roland D

    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!

    1. Diane Poremsky

      You'd add oAppt.ReminderSet = False to the code. Oh, and oAppt.Save.

  49. Roland D

    Dear Diane
    thanks for your fast reply. However, somehow it does not work....

    The code I have entered is
    --------------------------------------:

    Sub AutoAcceptMeetings(oRequest As MeetingItem)

    Dim oAppt As AppointmentItem
    Set oAppt = oRequest.GetAssociatedAppointment(True)

    Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingAccepted, True)

    oAppt.ReminderSet = False
    oAppt.Save

    End Sub

    -------------------------------------------
    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

    Thank you very much for your hint where the error might be....

    1. Diane Poremsky

      Does any of it work? It looks good - except you need to add oResponse.Close (olSave) to keep from sendinf the response.

      Sub AutoAcceptMeetings(oRequest As MeetingItem)

      Dim oAppt As AppointmentItem
      Set oAppt = oRequest.GetAssociatedAppointment(True)

      Dim oResponse
      Set oResponse = oAppt.Respond(olMeetingAccepted, True)
      oResponse.Close (olSave)

      oAppt.ReminderSet = False
      oAppt.Save

      End Sub

  50. Hans

    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.

    Any idea?

    My enviroment: Outlook Prof. Plus 2010/Exchange Server

    Many Greetings from Germany

    1. Diane Poremsky

      Try removing the If... End If block.

  51. Varada Raghu

    Hi Daine,

    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?

    1. Diane Poremsky

      Are you a delegate to the shared mailbox?

  52. Madison

    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!

    1. Diane Poremsky

      It would be "meeting cancellation" - and I'd probably use an if to look for the worked cancelled ,
      If Left(oAppt.Subject, 9) = "Canceled:" Then
      oAppt.Delete
      End if

  53. Pierre

    Not possible?

    1. Diane Poremsky

      it's possible- you need to move the declaration out of the () and into the macro:
      Sub AutoAcceptMeetings(oRequest As MeetingItem)

      Sub AutoAcceptMeetings()
      Dim oRequest As MeetingItem

      This works with selected item:
      Sub AcceptMeetings()
      Dim oRequest As MeetingItem
      Dim oAppt As AppointmentItem
      Set oRequest = Application.ActiveExplorer.Selection.Item(1)
      Set oAppt = oRequest.GetAssociatedAppointment(True)

      Dim oResponse
      Set oResponse = oAppt.Respond(olMeetingAccepted, True)
      oResponse.Send ' or .Display

      End Sub

  54. Brandon

    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

    1. Diane Poremsky

      You can add on If.. then statement to look for Update in first part of the subject and exit if found.

      If left(orequest.subject, 6) = "Update" then
      Exist Sub
      End if

      You can't autoaccept and leave the request in the inbox. If you want to autoaccept, you could create an email with the update.

  55. fabian

    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.

    1. Diane Poremsky

      Start here: copy meeting details

      you'd change the fields to this:
      oAppt.subject = "Downtime: " & cAppt.subject
      oAppt.Start = cAppt.End
      oAppt.Duration = 15

    2. Diane Poremsky

      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

      Dim oAppt As AppointmentItem
      Set oAppt = oRequest.GetAssociatedAppointment(True)

      Dim cAppt As AppointmentItem
      Set cAppt = Application.CreateItem(olAppointmentItem)
      cAppt.subject = "downtime: " & oAppt.subject
      cAppt.Start = oAppt.End

      cAppt.Duration = 15
      cAppt.Location = oAppt.Location
      cAppt.Save

      Dim oResponse
      Set oResponse = oAppt.Respond(olMeetingAccepted, True)
      oResponse.Display
      End Sub

  56. Larry

    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

    Dim oAppt As AppointmentItem
    Set oAppt = oRequest.GetAssociatedAppointment(True)

    Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingDeclined, True)
    oRequest.Display
    oRequest.Close
    oRequest.Delete
    oAppt.ReminderSet = False
    oAppt.Save

    End Sub

    1. Diane Poremsky

      The decline should remove it from the calendar.

      Did you try it without these two lines?
      oAppt.ReminderSet = False
      oAppt.Save

      This worked for me -
      Sub AutoDeclineMeetings(oRequest As MeetingItem)

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

      Dim oAppt As AppointmentItem
      Set oAppt = oRequest.GetAssociatedAppointment(True)

      Dim oResponse
      Set oResponse = oAppt.Respond(olMeetingDeclined, True)
      oResponse.Close (olSave)
      oRequest.Delete

      End Sub

  57. Larry

    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.

  58. Larry

    Also I'm using outlook 2013 not sure if that matters. But I have to manually click Decline with do not send a response for it to be removed from my calendar.

  59. larry

    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

    Dim oAppt As AppointmentItem
    Set oAppt = oRequest.GetAssociatedAppointment(True)
    oAppt.ReminderSet = False
    oAppt.Save
    Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingDeclined, True)
    oRequest.Close (olSave)
    oRequest.Delete

    End Sub

  60. Steve

    Can someone help with code that will delcine meetings if there is a conflict?

    1. Diane Poremsky

      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.

    2. Diane Poremsky

      This is why I get nothing done on.. someone asks a question that is more interesting than work. :)

      I added a macro to the page that appears to work - my math/logic might be off.

  61. Geert Roovers

    Hi! In the check for Free/Busy, you say "Next, you need to know how many time periods are between midnight and the appointment time (there are 120 5 minutes periods each day)"

    Now generally, in my 24 hour day, I have 288 5-minute periods (12 in an hour, 24 hours in a day, 24 * 12 = 288).

    Unfortunately, I cannot check if I need to change the values because of my second question:

    Set myAcct = Session.CreateRecipient("")

    Does not seem to work. At least the printout of myAcct doesn't yield anything. I'm using my e-mail address, but apparently the returned string is empty. Any ideas?

    Sorry for digging up an old thread, but people keep inviting me while I'm out of the office. Google brought me here.

  62. Geert Roovers

    Yea, I git it to work. I needed to use my user name instead of my full e-mail address in Session.CreateRecipient("").

    Also, I did need to change the 120 to 288. You just exchanged 12 5 minute periods in an hour to 5 12 minute periods :-)

    Thanks a bunch, this script is already making my out of office time easier to manage.

  63. Niveditha Pavani

    Hello,

    Without using a Rule, is there any code where Outlook picks the meeting request automatically from the Multiple mailbox for auto acceptance.

    1. Diane Poremsky

      If you want all meetings autoaccepted, you can configure outlook to accept them, but its all or nothing. You may need to log into each mailbox to configure it for each mailbox.

      You need to use a rule and script to autoaccept some but not all meetings.

  64. Niveditha Pavani

    I want all my Meetings to be auto accepted and delcined automatically without login from my primary account.I have typed the code as below. but it shows an error.
    Public Sub GetMails()

    Dim ns As NameSpace
    Dim myRecipient As Outlook.Recipient
    Dim aFolder As Outlook.Folders

    Set ns = GetNamespace("MAPI")

    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

    1. Diane Poremsky

      What line errors and what is the error message?

  65. jmkelley2

    Hi Diane,

    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?

    1. Diane Poremsky

      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.

    2. Diane Poremsky

      Some earlier posted this, which I missed at the time -

      Also, I did need to change the 120 to 288. You just exchanged 12 5 minute periods in an hour to 5 12 minute periods :-)

      It looks like I transposed the numbers when I calculated it. I'm dyslexic so that is entirely possible, but I still swear it worked with 120. :)

  66. Bardhi

    Which code should I use if i want, to accept calendar but NOT TO SEND RESPONSE. ?

    Thnx a lot ;)

    1. Diane Poremsky

      Change oresponse.display to
      oResponse.Close (olSave)

  67. BCPPS

    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.

    1. Diane Poremsky

      It mostly contains an error. Are any of the lines red? Did you test it before signing it?

  68. BCPPS

    I don't see anything red, and I don't know any other way of testing it other than to put it in service on my desktop and try to use it. Here's my code:

    Sub AutoDeclineMeetings(oRequest As MeetingItem)

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

    Dim oAppt As AppointmentItem
    Set oAppt = oRequest.GetAssociatedAppointment(True)

    Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingDeclined, True)
    oResponse.Display
    oRequest.Delete
    End Sub

    1. Diane Poremsky

      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.

      Sub AutoDeclineMeetingsTest()

      Dim oRequest As MeetingItem
      Set oRequest = Application.ActiveExplorer.Selection.Item(1)

      If oRequest.MessageClass <> "IPM.Schedule.Meeting.Request" Then
      MsgBox "not a meeting request"
      Exit Sub
      End If
      MsgBox "Step 1"
      Dim oAppt As AppointmentItem
      Set oAppt = oRequest.GetAssociatedAppointment(True)
      MsgBox "Step 2"
      Dim oResponse
      Set oResponse = oAppt.Respond(olMeetingDeclined, True)
      oResponse.Display
      oRequest.Delete
      End Sub

  69. Philippe Baguette

    Hi, working with Outlook 2013. Using the script hereunder. Does not seem to work at all. Have neither a new accepted appointment nor a response sent to the requester.

    Any hint ?

    Public Sub AutoAcceptMeetings(oRequest As MeetingItem)

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

    Dim oAppt As AppointmentItem
    Set oAppt = oRequest.GetAssociatedAppointment(True)
    oAppt.ReminderSet = True
    oAppt.Save
    Dim oResponse
    Set oResponse = oAppt.Respond(olMeetingAccepted, True)
    oRequest.Close (olSave)

    End Sub

    1. Diane Poremsky

      is macro security set to low? Did you select this script in the run a script action?

      Add msgbox "It's working!" as the first line and invite yourself to a meeting - does the dialog come up?

    2. Philippe Baguette

      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

      Dim oAppt As AppointmentItem
      Set oAppt = oRequest.GetAssociatedAppointment(True)

      Dim oResponse

      Set oResponse = oAppt.Respond(olMeetingAccepted, True)
      oResponse.Send
      oRequest.Delete

      End Sub

    3. Diane Poremsky

      Do you have any idea if the response is generated? oResponse.Send should send the response - if it's generated and sent, then the mail server is the problem.

  70. John Kendrick

    Is there any code that can be added to mark the all day event "free" when accepting before deleting the message

    1. Diane Poremsky

      oAppt is the associated appointment, so you'd use
      oAppt.BusyStatus = olFree
      oappt.save

      if you need to check for all day events, use
      If oAppt.AllDayEvent = True then
      ' set free and save
      end if

  71. Lawrence

    Finally! A rule for appointments! Thank you!

Leave a Reply

If the Post Comment button disappears, press your Tab key.

This site uses XenWord.