ThisOutlookSession

Alan McGowan

Senior Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server
I have the following code inThisOutlookSession which up until recently was working fine. However I have noticed that it has suddenly stopped triggering UserForm6 despite the condition of UserForm4.TextBox2.Value = "YES" being true. Any ideas why it would stop working? There is no error it simply doesn't appear to do anything when a sent email hits the Sent Mail folder.

Code:
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim Ns As Outlook.NameSpace
Set Ns = Application.GetNamespace("MAPI")
'use the default folder
Set Items = Ns.GetDefaultFolder(olFolderSentMail).Items
End Sub
Private Sub Items_ItemAdd(ByVal Item As Object)
  If TypeOf Item Is MailItem Then
    If UserForm4.TextBox2.Value = "YES" Then
        UserForm6.Show
    End If
  End If
End Sub
 
Top