Resolved Getting emails from a specific Outlook directory

PRDRISKELL

New member
Joined
Sep 25, 2020
Messages
2
Programming Experience
10+
I have a fully working program - here is a snippet
VB.NET:
Dim olfolder As Outlook.MAPIFolder

olfolder = objOL.GetNamespace("MAPI").PickFolder
This presents a list of every folder and sub-folder in my Outlook account, and I can pick the folder I want to read from and the rest of my code loops through just the email in that subfolder just fine.

Since I always pick the same folder ("\\Member\Updates") I would like to replace Line 2 with something like
VB.NET:
olfolder = objOL.GetNamespace("MAPI").UseFolder("\\Member\Updates")
but of course, there is no such method.

Can someone tell me the easiest way to do this without having to loop through every email in my Account?

You assistance greatly appreciated
 
Last edited by a moderator:

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,335
Location
Sydney, Australia
Programming Experience
10+
I've never used Outlook Interop before but, based on the following web search:
and the documentation links it returns, the GetNamespace method returns a Namespace object and that object has a Folders property that you can index by name to get a MAPIFolder object. That object has a similar Folders property so you can get a subfolder. Without having tested, my guess would be something like this:
VB.NET:
Dim olNamespace = objOL.GetNamespace("MAPI")
Dim olMemberFolder = olNamespace.Folders("Member")
Dim olUpdatesFolder = olMemberFolder.Folders("Updates")
That said, I've seen a number of examples that call GetDefaultFolder on the namespace first, so you might have to do that to get the inbox and then go down the folder hierarchy from there.
 

PRDRISKELL

New member
Joined
Sep 25, 2020
Messages
2
Programming Experience
10+
Thank you - Using this as a lead, I was able to simplify still further and it works ...

olfolder = objNS.Folders("Member").Folders("Updates")

This can be appended to, to whatever depth of sub folder is needed.

Thank you so much.
 
Top Bottom