Solved

Problem accessing public folder via vba

Posted on 2004-09-15
3
388 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

626 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