The idea for this macro came from Dan, who is looking for a way to assign a category when a meeting is accepted.
I would like to change the color of a meeting once the invitee accepts the invitation. Looking at my calendar if the meeting is still the default color I'd know I need to follow up to ensure they're going to attend. Do you know of a way to do this?
You can do this using a variation of our Autoaccept a Meeting Request using Rules macro, using it with a Run a Script rule to look for accepted meeting responses and then add a category to the associated appointment.
This method can be used to change any field in the associated appointment. Remember, if you change the subject, location, or time, Outlook will need to send an update.
How to use this macro
Open Outlook's VBA editor (Alt+F11), right click on Project1 and choose Insert > Module. Paste the code into the module, then create the rule with the 'run a script' Action and select this script.
Complete steps for using the VBA Editor and SelfCert are at How to use the VBA Editor
Sub AcceptedMeetings(oRequest As MeetingItem) If oRequest.MessageClass <> "IPM.Schedule.Meeting.Resp.Pos" Then Exit Sub End If Dim oAppt As AppointmentItem Set oAppt = oRequest.GetAssociatedAppointment(True) oAppt.Categories = "Green" oAppt.Save End Sub
Check for Declines
To categorize the meeting if any required attendee has declined, check for Declined responses then check the recipients list to see if any were required.
Sub CheckDeclines(oRequest As MeetingItem) ' only check declines If oRequest.MessageClass <> "IPM.Schedule.Meeting.Resp.Neg" Then Exit Sub End If Dim oAppt As AppointmentItem Set oAppt = oRequest.GetAssociatedAppointment(True) Dim objAttendees As Outlook.Recipients Dim objAttendeeReq As String Set objAttendees = oAppt.Recipients For x = 1 To objAttendees.Count If objAttendees(x).Type = olRequired Then oAppt.Categories = "Declined;" & oAppt.Categories End If Next oAppt.Save End Sub
Add Categories for Specific Attendees
To add a category based on the accepted recipients, use this script to check the recipient lists. This sets a category only if specific required attendees accept. As written, it uses their name as the category, but you can use a specific category (such as "Accepted") instead.
To use this to add a category named for each accepted attendees, move oAppt.Categories = objAttendeeReq & ";" & oAppt.Categories right after objAttendeeReq = objAttendees(x).Address and remove the lines following the first End If down to the last Next.
You can use attendee names or their email addresses, but the email address is generally more accurate for Internet addresses while the display name will work better for coworkers on Exchange server. You can check for the address then use the display name as the category.
Sub CategorizeMeetings(oRequest As MeetingItem) If oRequest.MessageClass <> "IPM.Schedule.Meeting.Resp.Pos" Then Exit Sub End If Dim oAppt As AppointmentItem Set oAppt = oRequest.GetAssociatedAppointment(True) Dim objAttendees As Outlook.Recipients Dim objAttendeeReq As String Set objAttendees = oAppt.Recipients For x = 1 To objAttendees.Count If objAttendees(x).Type = olRequired Then 'objAttendeeReq = objAttendees(x).Name objAttendeeReq = objAttendees(x).Address End If ' Set up the array to check for specific people arrRequired = Array("Diane Poremsky", "alias@domain.com", "diane@domain.com") ' Go through the array and look for a match, then do something For i = LBound(arrRequired) To UBound(arrRequired) If InStr(LCase(objAttendeeReq), arrRequired(i)) Then ' new cat first oAppt.Categories = objAttendeeReq & ";" & oAppt.Categories End If Next i Next oAppt.Save End Sub
To use these macros with declined or tentative responses, change the message class to one of the following message classes:
Message Class | Response |
---|---|
IPM.Schedule.Meeting.Resp.Pos | Accepted meeting response |
IPM.Schedule.Meeting.Resp.Neg | Declined meeting response |
IPM.Schedule.Meeting.Resp.Tent | Tentative meeting response |
More Information
More Run a Script Samples:
- Autoaccept a Meeting Request using Rules
- Automatically Add a Category to Accepted Meetings
- Blocking Mail From New Top-Level Domains
- Convert RTF Messages to Plain Text Format
- Create a rule to delete mail after a number of days
- Create a Task from an Email using a Rule
- Create an Outlook Appointment from a Message
- Create Appointment From Email Automatically
- Delegates, Meeting Requests, and Rules
- Delete attachments from messages
- Forward meeting details to another address
- How to Change the Font used for Outlook's RSS Feeds
- How to Process Mail After Business Hours
- Keep Canceled Meetings on Outlook's Calendar
- Macro to Print Outlook email attachments as they arrive
- Move messages CC'd to an address
- Open All Hyperlinks in an Outlook Email Message
- Outlook AutoReplies: One Script, Many Responses
- Outlook's Rules and Alerts: Run a Script
- Process messages received on a day of the week
- Read Outlook Messages using Plain Text
- Receive a Reminder When a Message Doesn't Arrive?
- Run a script rule: Autoreply using a template
- Run a script rule: Reply to a message
- Run a Script Rule: Send a New Message when a Message Arrives
- Run Rules Now using a Macro
- Run-a-Script Rules Missing in Outlook
- Save all incoming messages to the hard drive
- Save and Rename Outlook Email Attachments
- Save Attachments to the Hard Drive
- Save Outlook Email as a PDF
- Sort messages by Sender domain
- Talking Reminders
- To create a rule with wildcards
- Use a Macro to Copy Data in an Email to Excel
- Use a Rule to delete older messages as new ones arrive
- Use a run a script rule to mark messages read
- Use VBA to move messages with attachments
I have successfully created the 'run script' and copied/pasted the code to set up the auto change the meeting colour (to green as i see in the code it's written), however when I run the rule it does not work.
Any ideas?
Is macro security set to low?
You can test the macro on a selected items using this 'stub' macro. Change the macro name to be the same as your macro - select a meeting request in your inbox then run the macro.
Diane, I have been attempting to utilize this code for the past two days, but I have a disconnect somewhere that I cannot seem to correct. My problem seems to stem from the application of the category via vba. During my troubleshooting I used oAppt.Display and oAppt.ShowCategoriesDialog to attempt to detect why the category was not being added to the appointment after execution of the code. Apparently during the activation of the code the categories present are only the defaults ("Color Category"). But when opening the appointment or categories dialog manually I receive the full list of category options. Just for giggles I also tested the oRequest in the same fashion by opening the categories dialogue via vba, but in this case the dialog displays the full list of categories, and the code will successfully update the meeting invitation itself with any specified category. Also, even if I attempt to run the code for the update of the oAppt category as one of the default categories via vba, it doesn't update the appointment after activation of the code. My hypothesis is that it seems that the calendar environment is not accepting the input from the "default" categories dialogue when the… Read more Âğ
Thanks a lot for this, worked perfectly on only one occurrence meeting; do you have any code to check recurency meetings?
Example:
I have 10 meetings scheduled.
John accepts only 8 and decline 2 - I would like to see green on 8 and red on 2.
Is that possible?
Unfortunately, no. The categories are all or nothing for recurring appointments.
Diane,
First of all, thanks for putting this together. I have found this to be extremely helpful. This setup works wonderfully for single invitee meetings.
Of course when I run into something like this my mind starts to wander to more powerful uses.
So, here is the scenario:
I am an organizer of meetings with multiple attendees. There are several of these invitees that are mandatory and if they don't show up I need to reschedule the meeting. Or, I have a quorum that needs to be in attendance for these meetings.
The thought process would be similar. So, is there a way to pick out individual invitee responses and then use the category color coding to know visually if the meeting is good to go or needs to be rescheduled?
Again thanks so much. I find the code above to be brilliant!
you can use an if statement - you'll need to use the method at https://www.slipstick.com/developer/list-meeting-attendees-responses/ to get the attendesses and make a list of them.
if instr(1,strCopyData,"name") > 0 then
oAppt.Categories = "category" ";" & .categories
end if
to handle more than one name or category, you can use an array.
Thinking over this more... i think you would want to see if anyone who is required has declined, rather than a specific person - added a macro that does this.
https://www.slipstick.com/outlook/rules/add-category-accepted-meetings/#decline
So i got this to work for green with positive responses. But it does not work for yellow or red as i have assigned those to Tent and Neg responses. I did create yellow and red categories. I also created separate rules and test ran them independent. I want to add all three categories to an appointment as they respectively would apply. So for example if one person declines and two people will attend then it would be put into the green and red categories. If i test run the green category it works. I have my macros set to notify for all. Can anyone think of whats going on here? I am using outlook 365. Thank you
ass written, it replaces the categories already on the item. you need to add it like this:
oAppt.Categories = "Green" & ";" & .categories
Can a similar setup be used to automatically assign a category for all meeting invitations sent?
Not for ones you send, but you can do it using one of two options: a custom form that has a category set or an macro that sets the category. I'll see if i can find a macro that will work (my attemps at using an item add macro failed).
Script works great for me - thanks! Note that you need to have a "category" for "Green" set-up with a color assigned in order for the appointments to actually change color in the calendar view. At least in Outlook 2010, that is...
It works that way in all the modern versions of Outlook.
Hi Chip/Diana,
What exactly is the code for having a category for green set up? I am not able to figure that out. Thanks in advance!
I am getting an error message as the rule executes. It his highlighting this line of code:
Dim oAppt As AppointmentItemSet
The error states "Compile Error: User-defined type not defined"
Does it matter that I am using Outlook 2010?
That has part of another line added to it - it should end with appointmentitem and set goes on the next line.
Dim oAppt As AppointmentItem
Set