mallycat
05-08-2014, 07:45 PM
Hi
I want to write some code that moves an email from my inbox into a pre-specified folder, capture the EntryID and then immediately move to that email message in the explorer window at the new destination. I have the code written to get it there, but I don't know how to tell Outlook to open the destination folder and select the mail item. Can this be done? Any suggestions would be appreciated.
Matt
Sub MoveToFiled()
Dim myItem As Outlook.MailItem, myNewItem As Outlook.MailItem
Dim myProposedSubjectArray() As String
Set mynamespace = Application.GetNamespace("MAPI")
Set myDestFolder = mynamespace.Folders("myOutlook").Folders("Filed")
Set myItem = ActiveExplorer.Selection.Item(1)
Set myNewItem = myItem.Move(myDestFolder)
mynamespace.GetItemFromID (myNewItem.EntryID)
'jump to the item now it is in the new destination. Do not open it, just select it in Explorer
Set myItem = Nothing
Set myNewItem = Nothing
Set myDestFolder = Nothing
Set mynamespace = Nothing
End Sub
I want to write some code that moves an email from my inbox into a pre-specified folder, capture the EntryID and then immediately move to that email message in the explorer window at the new destination. I have the code written to get it there, but I don't know how to tell Outlook to open the destination folder and select the mail item. Can this be done? Any suggestions would be appreciated.
Matt
Sub MoveToFiled()
Dim myItem As Outlook.MailItem, myNewItem As Outlook.MailItem
Dim myProposedSubjectArray() As String
Set mynamespace = Application.GetNamespace("MAPI")
Set myDestFolder = mynamespace.Folders("myOutlook").Folders("Filed")
Set myItem = ActiveExplorer.Selection.Item(1)
Set myNewItem = myItem.Move(myDestFolder)
mynamespace.GetItemFromID (myNewItem.EntryID)
'jump to the item now it is in the new destination. Do not open it, just select it in Explorer
Set myItem = Nothing
Set myNewItem = Nothing
Set myDestFolder = Nothing
Set mynamespace = Nothing
End Sub