Change response to Outlook meeting and add text

460 Views Asked by At

I would like to change the response to a meeting, that I have accepted, to tentative and send text like "I'm sorry, but I cannot attend.".

Online, I found solutions that show how to accept, cancel, forward, and copy a meeting.

I also understood that I can open the message to edit before sending the reply with

Item.Respond(olMeetingTentative, False, False)

I would like to have it automated.

I tried the following

Sub tentativeOccurenceWithResponse()

Dim Item As Outlook.AppointmentItem
Dim response As Outlook.MeetingItem

For i = ActiveExplorer.Selection.Count To 1 Step -1
    Set Item = ActiveExplorer.Selection.Item(i)
    
    If TypeName(Item) = "AppointmentItem" Then
        
        If Item.ResponseRequested Then
            Set response = Item.Respond(olMeetingTentative, True)
            response.RTFBody = "Thank you for the invitation. Unfortunatelly, I cannot attend the meeting.\nPlease check my calendar for alternative time slots if my attendance is required."
            response.Send
        Else
            Item.MeetingStatus = olMeetingTentative
        End If
        
        Set Item = Nothing
    
    Else
        MsgBox "Sorry, you need to select an appointment"
    End If
Next

End Sub

The workflow:
I would like to go to my calendar and select meetings that I will not be able to join. Most of them are meeting serious or long time planned. Hence, it was not possible to react when I got the invitation.
I want to notify all Meeting organizers that I cannot attend, but I would like to get updates and might still be able to join in case of vacation changes. (So no decline here.)

1

There are 1 best solutions below

2
On

First of all, you need to declare the item as a generic object because Outlook folders may contain different kind of items:

Dim Item As Object

Then in the loop you can check out the message class and only after making sure the item is an appointment you can cast it to the required type and process the item further.


For i = ActiveExplorer.Selection.Count To 1 Step -1
    Set Item = ActiveExplorer.Selection.Item(i)
    
    If TypeName(Item) = "AppointmentItem" Then


If you need to handle incoming items automatically you can handle the NewMailEx event of the Application class which is fired when a new message arrives in the Inbox and before client rule processing occurs. This event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem. The EntryIDsCollection string contains the Entry ID that corresponds to that item. So, you are interested in processing meeting items only. To recognize the item you need to get an instance of the incoming Outlook item. Use the Entry ID returned in the EntryIDCollection string to call the NameSpace.GetItemFromID method and process the item.

Also you may consider hooking up the ItemAdd event on the folder. The event is fired when one or more items are added to the specified collection. Note, this event does not run when a large number of items are added to the folder at once.