I used the code you originally posted and this code, which is from post #7.
Option Explicit
Private WithEvents oItems As Outlook.Items
Private Sub Application_Startup()
Const MyFolder = "Controls" ' <-- Change to suit
On Error Resume Next
With Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
Set oItems = .Folders(MyFolder).Items
If Err Then
.Folders.Add MyFolder
Set oItems = .Folders(MyFolder).Items
End If
End With
On Error GoTo 0
End Sub
I didn't use the rest of the code from that post because the oItems_ItemAdded sub didn't have the Exit Sub the original code had.
Here's the full code I used.
Option Explicit
Private WithEvents oItems As Outlook.Items
Private Sub Application_Startup()
Const MyFolder = "Test" ' <-- Change to suit
On Error Resume Next
With Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
Set oItems = .Folders(MyFolder).Items
If Err Then
.Folders.Add MyFolder
Set oItems = .Folders(MyFolder).Items
End If
End With
On Error GoTo 0
End Sub
Private Sub oItems_ItemAdd(ByVal Item As Object)
Static N
If IsNumeric(N) Then N = N + 1
N = InputBox("Type ID to be added to the end of the Subject", "Subject ID", N)
If N = "" Then Exit Sub
With Item
.Subject = .Subject & " " & N
.Save
End With
End Sub
PS I changed MyFolder in to 'Test' to suit.
Bookmarks