I am trying to move a particular message class to the deleted folders as soon as it arrives in the mailbox.
The script works but throws out an error - 91 with Line Set objItem = objOutlook.ActiveInspector.CurrentItem. I can't figure out where my issues are. I also want to add the OL for automatic reply for out of office email. Anyone have an answer?
The script works but throws out an error - 91 with Line Set objItem = objOutlook.ActiveInspector.CurrentItem. I can't figure out where my issues are. I also want to add the OL for automatic reply for out of office email. Anyone have an answer?
Code:
Sub MoveMessageClass(Item As Outlook.MailItem)
'Move email to the deleted items folder if it is of a particular message class
Dim objOutlook As Outlook.Application
Dim objNamespace As Outlook.NameSpace
Dim objSourceFolder As Outlook.MAPIFolder
Dim objDestFolder As Outlook.MAPIFolder
Dim objItem As MailItem
' Housekeeping: set up the macro environment
Set objOutlook = Application
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objSourceFolder = objNamespace.GetDefaultFolder(olFolderInbox)
Set objDestFolder = objNamespace.GetDefaultFolder(olFolderDeletedItems)
' Set objItem = objSourceFolder.Items
' Item inspection
Set objItem = objOutlook.ActiveInspector.CurrentItem
' Move objItems with the message classes in the CASE
Select Case objItem
Case olMeetingResponseNegative, olMeetingResponsePositive, olMeetingRequest, olMeetingAccepted, olMeetingTentative
objItem.Move objDestFolder
End Select
End Sub