mmartinez74
Technical User
I am trying to understand how VBA in outlook works.
I created the following routine, which looks for a new message with the subject of %Test% and then displays a message box with the sender's name. But I get an error that says 'Object variable not set' What do I need to set?
Private Sub Application_NewMail()
Dim omMail As MailItem
Set ofFolder = Application.GetNamespace("MAPI".GetDefaultFolder(olFolderInbox)
If omMail.Subject = "%Test%" Then MsgBox (omMail.SenderName)
End Sub
I created the following routine, which looks for a new message with the subject of %Test% and then displays a message box with the sender's name. But I get an error that says 'Object variable not set' What do I need to set?
Private Sub Application_NewMail()
Dim omMail As MailItem
Set ofFolder = Application.GetNamespace("MAPI".GetDefaultFolder(olFolderInbox)
If omMail.Subject = "%Test%" Then MsgBox (omMail.SenderName)
End Sub