Solved

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

Posted on 2003-11-02
6
3,508 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
  • 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

821 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