Auto decline calendar meeting to a specific email address (distribution list - group)

88 Views Asked by At

I am trying to create a VBA that will auto decline and delete all calendar invites that goes from users in the business to a SPECIFIC email (DL/Group). For business purpose I cannot remove myself from that group to receive all the emails just in case, but that also automatically adds invites into my calendar.

So far I have used this: https://www.extendoffice.com/documents/outlook/5054-outlook-auto-decline-meeting-from-specific-person.html

The problem is that it points to:

If VBA.LCase(xMeeting.SenderEmailAddress) = VBA.LCase("[email protected]") Then

I cannot find a command that will allow me to turn it into something such as: xMeeting.(Receiver/Receipient)EmailAddress

Is there any chance this could be done?

Also, I am using Outlook 365 and I have no option in rules management to select "Run a script". Is there any other way of doing it?

It messes up my calendar so much I need to find a way of doing it.

Thanks in advance!

Created a rule:

  • sent to people or public group
  • with specific words in the subject
  • which is a meeting invitation or update

Added the VBA code from the link above and not sure how to change it to recipient instead of a sender. Also not having an option to select "run script" in rules.

1

There are 1 best solutions below

2
Eugene Astafiev On

I cannot find a command that will allow me to turn it into something such as: xMeeting.(Receiver/Receipient)EmailAddress

Sounds like the sender email address is already known:

If VBA.LCase(xMeeting.SenderEmailAddress) = VBA.LCase("[email protected]") Then

To get the recipient(s) of the item you need to use the corresponding property of Outlook items - the Recipients property returns a Recipients collection that represents all the recipients for the Outlook item. Use Recipients(index), where index is the name or index number, to return a single Recipient object. The MeetingItem recipient can be one of the following OlMeetingRecipientType constants: olOptional, olOrganizer, olRequired, or olResource (see the Type property). For example:

Sub DemoMeetingRecipients() 
 Dim myAppointment As Outlook.AppointmentItem 
 Dim myPA As Outlook.PropertyAccessor 
 Dim d As Long 
 Dim myInt As Long 
 
 Set myAppointment = Application.ActiveInspector.CurrentItem 
 
 For d = 1 To myAppointment.Recipients.count 
 Debug.Print myAppointment.Recipients.item(d).name 
 Debug.Print myAppointment.Recipients.item(d).Type 
 Set myPA = myAppointment.Recipients.item(d).PropertyAccessor 
 myInt = myPA.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x39050003") 
 Debug.Print myInt 
 Debug.Print "---" 
 Next d 
End Sub