Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2003-11-02
6
Medium Priority
?
3,535 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 800 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

721 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