problem accessing public folder programmatically...

S

Shshank

I am facing a problem accessing the Public Folder.
The code just hangs at the point where I try to access
the "Public Folders" folder.

Here's a code snippet.
Dim ol as Outlook.Application
Dim olns as Outlook.NameSpace
Dim myFlr1 as Outlook.mapiFolder
Dim myFlr2 as Outlook.mapiFolder

Set ol = New Outlook.Application
Set olns = ol.GetNameSpace("MAPI")

Set myFlr1 = olns.Folders("Public Folders") <---- HANGS !
Set myFlr2 = myFlr1.Folders("All Public Folders")

.... ... ...
.... ... ...

Hope somebody can help.
Thanks
-Shshank
 
K

Ken Slovak - [MVP - Outlook]

S

Shshank

I tried this also. But it doesnt work.
The code just hangs there.

Set myFlr1 = olns.Folders("Public Folders") _
.Folders("All Public Folders").Folders("MyFolder")
 
S

Shshank

I tried this also. But it doesnt work.
The code just hangs there.

Set myFlr1 = olns.Folders("Public Folders") _
.Folders("All Public Folders").Folders("MyFolder")
-----Original Message-----
Does the code work if you access the folder under All Public Folders?

Set myFlr1 = olns.Folders("Public Folders") _
.Folders("All Public Folders").Folders("MyFolder")


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Shshank said:
I am facing a problem accessing the Public Folder.
The code just hangs at the point where I try to access
the "Public Folders" folder.

Here's a code snippet.
Dim ol as Outlook.Application
Dim olns as Outlook.NameSpace
Dim myFlr1 as Outlook.mapiFolder
Dim myFlr2 as Outlook.mapiFolder

Set ol = New Outlook.Application
Set olns = ol.GetNameSpace("MAPI")

Set myFlr1 = olns.Folders("Public Folders") <---- HANGS !
Set myFlr2 = myFlr1.Folders("All Public Folders")

... ... ...
... ... ...

Hope somebody can help.
Thanks
-Shshank


.
 
D

David Portabella

Dim ol as Outlook.Application
Dim olns as Outlook.NameSpace
Dim myFlr1 as Outlook.mapiFolder
Dim myFlr2 as Outlook.mapiFolder

Set ol = New Outlook.Application
Set olns = ol.GetNameSpace("MAPI")

Set myFlr1 = olns.Folders("Public Folders") <---- HANGS !

Taking a look to the documentation, I don't see that you can get the folder
by the name.
Instead, try this:
Dim folders AS Outlook.Folders
Set folders = olns.Folders
Dim i as Integer
For i = 1 to folders.Items.Count
Dim folder as Outlook.mapiFolder
Set folder = folders.Items(i)
Console.WriteLine(folder.Name)
'...
Next

HTH,
David
 
K

Ken Slovak - [MVP - Outlook]

Is there an error message of some kind? The code should certainly
work. Is the public folders tree showing in the UI when you look at
it? Can you access other folders in the Mailbox?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top