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.
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", "firstname.lastname@example.org", "email@example.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:
|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 Run a Script Samples:
- Autoaccept a Meeting Request using Rules
- 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 Appointment From Email Automatically
- Delegates, Meeting Requests, and Rules
- 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
- 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: Change Subject then Forward Message
- 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 2016
- Sort messages by Sender domain
- To create a rule with wildcards
- Use a Rule to delete older messages as new ones arrive