PDA

View Full Version : Jump to email based on EntryID



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

westconn1
05-12-2014, 05:41 AM
it should be
ActiveExplorer.CurrentFolder = mydestfolder
but it is not working correctly for me

adz
07-01-2014, 10:00 PM
This is the best I can do ... it should get you there ... but activeexplorer cannot scroll so you will have to memorize the date and scroll manually to the selected mail item.

Sub SearchPerson()
Set oItem = GetCurrentItem
vs_sender = oItem.SenderEmailAddress
vs_recip = ""
For Each vo_recip In oItem.Recipients
vs_recip = vo_recip.Name + "; "
Next
If RegExMatch(vs_recip, "adam[ .]la", , True) Then
vs_search = vs_sender
Else
vs_search = vs_recip
End If
Dim myOlApp As New Outlook.Application
txtSearch = vs_search 'folder:Inbox received: (this week)
myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
Set myOlApp = Nothing

End Sub

BTW vbaexpress registration and http limitation sux
Sub SearchClear()
Set oItem = GetCurrentItem
vs_id = oItem.EntryID
Dim myOlApp As New Outlook.Application
vs_1 = oItem.Parent.FullFolderPath
vs_folder = GetFolder(vs_1)
Set Application.ActiveExplorer.CurrentFolder = oItem.Parent
DoEvents
Application.ActiveExplorer.ClearSelection
DoEvents
Application.ActiveExplorer.AddToSelection (oItem)
'does NOT Automatically scroll into view
End Sub