Solved

Problem accessing public folder via vba

Posted on 2004-09-15
3
384 Views
Last Modified: 2010-04-08
I'm trying to get access to our public folder using vba in Outlook.  Our system is connected to an exchange server.  The public folder is outside of my account.  So for example when i open outlook i have my mail box called "x Personal Email" and on the same level there is a folder called "Public Folders" so its not in my personal email but at the same level.  The public folder is a company wide public folder that everyone has access to.  I goal is to write a tool that reads this a particular sub-folder specific to my project and process the undeliverable emails.

Here is my code:

    Set objApp = New Outlook.Application
    Set objNameSpace = objApp.GetNamespace(Type:="MAPI")
    Set objMAPIFolder = _
        objNameSpace.GetDefaultFolder(FolderType:=olPublicFoldersAllPublicFolders) _
        .Folders("Public Folders") _
        .Folders("All Public Folders").Folders("Company").Folders("Undeliverable Letters")
       

   
    For Each objMailItem In objMAPIFolder.Items
        ' Uncomment the next line if you want to verify results.
        ' Debug.Print objMailItem.SentOn & vbTab & _
            objMailItem.Subject
       
        If objMailItem.SentOn < Date Then
            lngOldMailCounter = lngOldMailCounter + 1
        Else
            lngNewMailCounter = lngNewMailCounter + 1
        End If
   
    Next objMailItem

But i fail right when i step over objMAPIFolder .

I'm sure i'm doing something wrong but can anyone guide me in fixing this problem.

THanks

0
Comment
Question by:borg48
  • 2
3 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 12070369
what is the exact error message?
0
 

Author Comment

by:borg48
ID: 12070419
Could not complete the operation.  One or more parameter values are not valid.

But if i just put the first folder "Public Folders" i get the same error.  So i think its the root folder that i'm not getting correct.
0
 
LVL 44

Accepted Solution

by:
bruintje earned 80 total points
ID: 12070468
last post for today

maybe you find something useful in here
source : http://tinyurl.com/4gha5

it scetches a likewise problem and the solution was use your own const dimmed as long to substitute for early binding constants of the outlook object itself you could try this for the olPublicFoldersAllPublicFolders etc.....
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
Read this checklist to learn more about the 15 things you should never include in an email signature.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now