Getting Sub Folder Access 
Author Message
 Getting Sub Folder Access

I have been working with the automation freature of
Outlook 2000 in both VB and C++.  I can get the default
Inbox and read messages, but I can not get at the sub
folders under InBox.

The Knowledge base suggested

fldMail = NameSpace.Folders("Inbox Folder").Folders("Cars")

But VB rejects this construct. There has to be an easy way
to get at a sub folder under the default mail folder??

Thanks



Fri, 11 Mar 2005 18:55:44 GMT  
 Getting Sub Folder Access
There probably is no folder named "Inbox Folder." The default name is
"Inbox," but an easier way to return that folder is the
Namespace.GetDefaultFolder method.

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
     Microsoft Outlook Programming Jumpstart - coming September 2002
     http://www.slipstick.com/books/jumpstart.htm



Quote:
> I have been working with the automation freature of
> Outlook 2000 in both VB and C++.  I can get the default
> Inbox and read messages, but I can not get at the sub
> folders under InBox.

> The Knowledge base suggested

> fldMail = NameSpace.Folders("Inbox Folder").Folders("Cars")

> But VB rejects this construct. There has to be an easy way
> to get at a sub folder under the default mail folder??

> Thanks



Fri, 11 Mar 2005 19:31:25 GMT  
 Getting Sub Folder Access
Sue,

You miss my problem.  I can get to Inbox with the
Namspace.GetDefaultFolder.  The name I see in the
description field when I do this is "Inbox Folder".  Yet
that is immaterial.  I want to get to the mail messages in
the "Cars" folder under Inbox. So far I have not been able
to get access.  The examples I found in the Knowledge base
have syntax errors and are not recognized by Visual Basic
NET.  I am trying to access the subfolders in Outlook 2000
with the latest Office Service packs installed.

I can see the method Folders and the count is of three for
three sub floders in correct, but I have not found a
syntax to get to the sub folder.

Thanks

Quote:
>-----Original Message-----
>There probably is no folder named "Inbox Folder." The
default name is
>"Inbox," but an easier way to return that folder is the
>Namespace.GetDefaultFolder method.

>--
>Sue Mosher, Outlook MVP
>Outlook and Exchange solutions at http://www.slipstick.com
>Author of
>     Microsoft Outlook Programming Jumpstart - coming
September 2002
>     http://www.slipstick.com/books/jumpstart.htm



>> I have been working with the automation freature of
>> Outlook 2000 in both VB and C++.  I can get the default
>> Inbox and read messages, but I can not get at the sub
>> folders under InBox.

>> The Knowledge base suggested

>> fldMail = NameSpace.Folders("Inbox Folder").Folders
("Cars")

>> But VB rejects this construct. There has to be an easy
way
>> to get at a sub folder under the default mail folder??

>> Thanks

>.



Sat, 12 Mar 2005 15:19:58 GMT  
 Getting Sub Folder Access
OK, I think you have variable type confusion and missing Set command.

Firstly - ensure you have Option Explicit at the top of every module (form,
class, etc). If you do not do this, you can create variant variables by
accident by mistyping variable names.
Next - Ensure you declare (Dim, Private, Public) every variable you use with
an explicit datatype for each one. Without this your variables can be
variants by accident which can be confusing.
Lastly - whenever you assign an object to a variable, you must use the Set
command. If you don't say Set you may assign just the default property of
the object rather than the whole object. EG you get a string
name/description of the object by accident.

Here is some code that I think will do what you want, though I haven't
tested it.

--------------------------
Option Explicit

Sub Something()
    Dim objOutlook As Outlook.Application
    Dim objNameSpace As Namespace
    Dim objInboxFolder As MAPIFolder
    Dim objCarsFolder As MAPIFolder

    Set objOutlook = New Outlook.Application
    Set objNameSpace = objOutlook.GetNameSpace("MAPI")
    Set objInboxFolder = objNameSpace.GetDefaultFolder(olInbox)
    Set objCarsFolder = objInboxFolder.Folders("Cars")

    MsgBox objCarsFolder.FolderPath, vbInformation + vbOkOnly
End Sub
--------------------------
--

Regards,
Simon Jones
MillStream Designs Ltd
Independent IT Consultants



Quote:
> Sue,

> You miss my problem.  I can get to Inbox with the
> Namspace.GetDefaultFolder.  The name I see in the
> description field when I do this is "Inbox Folder".  Yet
> that is immaterial.  I want to get to the mail messages in
> the "Cars" folder under Inbox. So far I have not been able
> to get access.  The examples I found in the Knowledge base
> have syntax errors and are not recognized by Visual Basic
> NET.  I am trying to access the subfolders in Outlook 2000
> with the latest Office Service packs installed.

> I can see the method Folders and the count is of three for
> three sub floders in correct, but I have not found a
> syntax to get to the sub folder.

> Thanks

> >-----Original Message-----
> >There probably is no folder named "Inbox Folder." The
> default name is
> >"Inbox," but an easier way to return that folder is the
> >Namespace.GetDefaultFolder method.

> >--
> >Sue Mosher, Outlook MVP
> >Outlook and Exchange solutions at http://www.slipstick.com
> >Author of
> >     Microsoft Outlook Programming Jumpstart - coming
> September 2002
> >     http://www.slipstick.com/books/jumpstart.htm



> >> I have been working with the automation freature of
> >> Outlook 2000 in both VB and C++.  I can get the default
> >> Inbox and read messages, but I can not get at the sub
> >> folders under InBox.

> >> The Knowledge base suggested

> >> fldMail = NameSpace.Folders("Inbox Folder").Folders
> ("Cars")

> >> But VB rejects this construct. There has to be an easy
> way
> >> to get at a sub folder under the default mail folder??

> >> Thanks

> >.



Sat, 12 Mar 2005 15:48:03 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Build XML of folders, sub folders and files from specified folder

2. Creating (sub-sub-)folders

3. Validate contact in sub folder from Access

4. Problem Accessing sub-folders ? in VB using CDO

5. Access sub folders in Outlook

6. Enumerate a Folder and it's Sub Folders

7. To get the names of folders and sub folders

8. Find Sub Folder Name within a Folder

9. Deleting certian Files in Folders and there sub folders

10. Copy the files and sub folders to another folder

11. Help Requested: Getting Access to select folders in an Explorer Window

12. Can't access records with sub form for linked sub table

 

 
Powered by phpBB® Forum Software