Option Explicit Private WithEvents Items As Outlook.Items Private Sub Application_Startup() Dim Ns As Outlook.NameSpace Set Ns = Application.GetNamespace("MAPI") Set Items = Ns.GetDefaultFolder(olFolderInbox).Items End Sub Private Sub Items_ItemAdd(ByVal Item As Object) If InStr(1, Item.Subject, "Accepted: ") Then GoTo SendReply Else Exit Sub End If SendReply: ' don't send autoreply if one was already sent If InStr(1, LCase(Item.Subject), "re:") Or InStr(1, LCase(Item.Subject), "fw:") Then Exit Sub ' to avoid sending an autoreply to a follow-up message End If Dim oRespond As Outlook.MailItem Dim RmSize As String Dim strSubject As String Dim arrSubject As Variant Dim arrRmSize As Variant Dim i As Long ' Set up the array arrSubject = Array("Testing this meeting", "Testing the macro", "More Testing", "meeting subject 4") arrRmSize = Array("2", "2", "2", "2", "2") ' Go through the array and look for a match, then do something For i = LBound(arrSubject) To UBound(arrSubject) If InStr(Item.Subject, arrSubject(i)) Then RmSize = arrRmSize(i) strSubject = arrSubject(i) Debug.Print RmSize Debug.Print strSubject Dim Accepted As String Dim fso Dim f1 Dim File As String File = "C:\Users\drcp\Documents\macro-test.txt" Set fso = CreateObject("Scripting.FileSystemObject") If Not fso.FileExists(File) Then 'create Set f1 = fso.CreateTextFile(File, True) f1.Close End If Dim objWord As Word.Application Set objWord = New Word.Application Accepted = objWord.System.PrivateProfileString(File, strSubject, "Accepted") If Accepted = "" Then Accepted = 1 Else Accepted = Accepted + 1 End If objWord.System.PrivateProfileString(File, strSubject, "Accepted") = Accepted If Accepted >= RmSize Then Set oRespond = Application.CreateItem(olMailItem) With oRespond .Recipients.Add Item.SenderEmailAddress .Subject = "Sorry: " & strSubject .Body = " Sorry, the room is full. You're on the waiting list. You are " & Accepted - RmSize & " on the waiting list." ' use .display for testing, .send after it is working as desired '.Display .Send End With Set oRespond = Nothing End If End If Next i End Sub