Hi,
I want to move the mail from a particular recepients/subject to a folder in the outlook using macros.
I got the code for the same as below from google. But still it is showing the error as "Target folder not found". I dont know what this line "("Mailbox - Jim Merrell")." says below
Where i needs to mention the recepients name/mail/subject in the below code.
The folder name is Finance
'Outlook VB Macro to move selected mail item(s) to a target folder
Sub MoveToFiled()
On Error Resume Next
Dim ns As Outlook.NameSpace
Dim moveToFolder As Outlook.MAPIFolder
Dim objItem As Outlook.MailItem
Set ns = Application.GetNamespace("MAPI")
'Define path to the target folder
Set moveToFolder = ns.Folders("Mailbox - Jim Merrell").Folders("Finance")
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
End Sub
Can anyone help me ?
Thanks in advance
Regards,
Arun
Bookmarks