Solved

VBA: How to create a personal folder in Outlook using VBA

Posted on 2006-07-12
1
814 Views
Last Modified: 2008-03-10
Hi,

I have to create a personal folder using VBA.  Any idea how can I acheive the same programmatically ?

I don't need the manual methods as I am also aware of the same.

Please let me know some script/code for creating a personal folder. Any appropriate link is also sufficient.

Regards,
Vikas.
0
Comment
Question by:TiwariVikas
1 Comment
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 17095041
Greetings, TiwariVikas.

Use the AddStore method of the NameSpace object.  Here's a function I wrote for another question that creates an archive (PST) file for a given year.  I've added comments to help make sense of it.

Sub CreateYearlyPST(strYear As String, strArchiveFileName As String)
    Dim olkNS As Outlook.NameSpace, _
        olkFolder As Outlook.MAPIFolder
    'Create a NameSpace object
    Set olkNS = Application.GetNamespace("MAPI")
    'Create the new PST file using the name passed
    olkNS.AddStore strArchiveFileName
    'Get the root folder in the new PST file.  OpenMAPIFolder is a custom function.  I can post the code if you need.
    Set olkFolder = OpenMAPIFolder("\Personal Folders")
    'Create a fodler called Inbox
    olkFolder.Folders.Add "Inbox", olFolderInbox
    olkFolder.Name = strYear
    olkNS.RemoveStore olkFolder
    Set olkFolder = Nothing
    Set olkNS = Nothing
End Sub

Cheers!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
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…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

730 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