Solved

How do you select a "personal" Outlook folder using vba code

Posted on 2003-11-02
6
3,524 Views
Last Modified: 2010-08-05
OK, I can get the properties of the default  Calendar folder in Outlook using the following code:

   Dim ol As New Outlook.Application
   Dim olns As Outlook.Namespace
   Dim cf As Outlook.MAPIFolder
   Dim c As Outlook.AppointmentItem
   Dim objItems As Outlook.Items
   Dim Prop As Outlook.UserProperty
   Dim k As Integer
   Set olns = ol.GetNamespace("MAPI")
   Set cf = olns.GetDefaultFolder(olFolderCalendar)

If I have a stand-alone  pst file, how would I get access to that file?
 
If this isn't possible, then how would I get access to personal calendar file within Outlook?
This file would be under a personal folder called  PRC, then the subfolder called Calendar and then another
subfolder called  Church.
0
Comment
Question by:Mach1pro
[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
  • 4
6 Comments
 
LVL 17

Expert Comment

by:Suat Ozgur
ID: 9668469
'----
Dim ol As New Outlook.Application
Dim olns As Outlook.NameSpace
Dim cf As Outlook.MAPIFolder
Dim cal As Outlook.MAPIFolder
 
  Set olns = ol.GetNamespace("MAPI")
  Set cf = olns.Folders("PRC")
  Set cal = cf.Folders("Calendar")
'----

What you need is cal object.

Suat
0
 
LVL 17

Expert Comment

by:Suat Ozgur
ID: 9668540
Okay, to make it easy for you to let you use your own code still:

Dim ol As New Outlook.Application
Dim olns As Outlook.NameSpace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.AppointmentItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty
Dim k As Integer
    Set olns = ol.GetNamespace("MAPI")
    Set cf = olns.Folders("PRC").Folders("Calendar")

Suat
0
 
LVL 17

Accepted Solution

by:
Suat Ozgur earned 200 total points
ID: 9668589
Or...

Set cf = olns.Folders("PRC").Folders("Calendar").Folders("Church")

or for this folder structure:

-PRC
--Calendar
----Church
--------OtherOne
------------AnotherOne

Set cf = olns.Folders("PRC").Folders("Calendar").Folders("Churc").Folders("OtherOne").Folders("AnotherOne") '.....

Does this solve your problem or do you need another information ? Please let us know.

Suat
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 6

Author Comment

by:Mach1pro
ID: 9668760
This is great.

I will still offer 200 more points though if someone will show me how to make the connection to a
stand alone pst file.
0
 
LVL 17

Expert Comment

by:Suat Ozgur
ID: 9669503
Sorry, I don't know how to read a pst file outside of Outlook. I hope someone else does.

Suat
(Thanks for the grade)
0
 

Expert Comment

by:insideoud
ID: 10047670
This should answer yout question:

Sub ExploreFolders()
    Dim ol As New Outlook.Application
    Dim ns As Outlook.NameSpace
    Dim fds As Outlook.Folders
    Dim fd As Outlook.MAPIFolder

    Set ns = ol.GetNamespace("MAPI")
    'Set a reference to all folders within
    'a personal folder called development
    Set fds = ns.Folders("Development").Folders

    'Loop through all of the folders looking
    'for one named Acme.
    For Each fd In fds
        If fd.Name = "Acme" Then
            Exit For
        End If
    Next

    'Display the name of the parent folder
    MsgBox fd.Parent
End Sub
 
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

635 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