Solved

Problem accessing public folder via vba

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
Outlook Free & Paid Tools
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

13 Experts available now in Live!

Get 1:1 Help Now