Solved

Problem accessing public folder via vba

Posted on 2004-09-15
3
386 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

If you don't know how to downgrade, my instructions below should be helpful.
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 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