Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need full path of Outlook subfolder

Status
Not open for further replies.

Jtorres13

Technical User
Nov 11, 2006
162
US
I'm on Outlook 2003 SP3 using Exchange 2003. I'm not using any .PST. In my profile I have my mailbox and an additional mailbox I setup through Tools | Accounts | View (mine) | Change | More Settings | Advanced | Add...

So, now in my Navigation Pane I have two mailboxes. This second mailbox is a collection of folders and nested subfolders many levels deep in some cases.

If I need to find a series of emails to do research, I do a search and the search results screen tells me the folder where the email I want is located. But, that may not be the email I need. Maybe I need to go to the folder that contais that email and read through the emails and analyze the info, etc.

The problem is that there can be 10 or more folders with the same name, all in different subfolders, different branches. So, just knowing the containing folder doesn't help. I need the full path.

I found a snipet of code that I think might help, but it's only giving me the root folder \\mailbox\Doe, John\Inbox. I need it to go deeper and return the full path, including all subfolders. Is this possible?

Here's the code I'm using:
Code:
Public Sub Findpath()
 Dim myRecipient As Outlook.Recipient
    Dim olFolder As Outlook.MAPIFolder
    Set myolapp = CreateObject("Outlook.Application")
    Set myNamespace = myolapp.GetNamespace("MAPI")
    Set myRecipient = myNamespace.CreateRecipient("Doe, John")
    Set olFolder = myNamespace.GetSharedDefaultFolder(myRecipient, olFolderInbox)
    MsgBox olFolder.FolderPath
End Sub

I hope I've explained the problem well, but if you need more information, please let me know. I would like to figure this out.
 
Jtorres13,
Not sure what method your using to search for messages but you should be able to use [tt]MailItem.Parent.FolderPath[/tt]

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Well, you didn't get the golden star but you made me look more closely at the different objects and i changed things around and found this:
Code:
Public Sub Findpath()
    
    MsgBox ActiveExplorer.CurrentFolder.FolderPath

End Sub

I think I was using the wrong object before getting the FolderPath. So now I run the search, click an email, run the macro and voila. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top