K
Keith Brown
I have several macros setup to move emails from my inbox to a specified
folder. I would like to know how to move calendar items such as meeting
requests, replies from people when they accept or decline a meeting invite,
etc. to a folder using a macro as well. Below is the macro I use to move
email items to a folder called "California", a sub-folder of my Inbox. I
want to know if I can modify this macro to also include moving calendar
items. if not, I would like to know what I need to do to move calendar items.
Sub MoveToCalifornia()
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Folders("California") 'Assume this is a mail
folder
If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If
If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a message is selected
Exit Sub
End If
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Categories = "Personal"
objItem.Move objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub
folder. I would like to know how to move calendar items such as meeting
requests, replies from people when they accept or decline a meeting invite,
etc. to a folder using a macro as well. Below is the macro I use to move
email items to a folder called "California", a sub-folder of my Inbox. I
want to know if I can modify this macro to also include moving calendar
items. if not, I would like to know what I need to do to move calendar items.
Sub MoveToCalifornia()
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Folders("California") 'Assume this is a mail
folder
If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If
If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a message is selected
Exit Sub
End If
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Categories = "Personal"
objItem.Move objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub