I have considered doing this, but we have so many emails coming in that need grooming that we have reached the maximum number of rules.
The macro itself works.
if I put a different folder in (for example 'Sent') it moves the email. it's just with the way the subfolder is positioned that seems to be my challenge.
This is the complete code I have:
'Outlook VB Macro to move selected mail item(s) to a target folder
Sub MoveSelectedEmailToDeistalls()
On Error Resume Next
Dim ns As Outlook.NameSpace
Dim moveToFolder As Outlook.MAPIFolder
Dim objItem As Outlook.MailItem
Dim MyItem As Object
Set ns = Application.GetNamespace("MAPI")
Set MyItem = ActiveExplorer.Selection(1)
' mark selected email as READ
MyItem.UnRead = False
'Define path to the target folder
Set moveToFolder = ns.Folders("marijkemail@mailbox.com").Folders("ToDo")
If Application.ActiveExplorer.Selection.Count = 0 Then
MsgBox ("No item selected")
Exit Sub
End If
If moveToFolder Is Nothing Then
MsgBox "Target folder not found!", vbOKOnly + vbExclamation, "Move Macro Error"
End If
For Each objItem In Application.ActiveExplorer.Selection
If moveToFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move moveToFolder
End If
End If
Next
Set objItem = Nothing
Set moveToFolder = Nothing
Set ns = Nothing
Set MyItem = Nothing
End Sub
Bookmarks