Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Macro to create folder in PST file (http://www.outlookbanter.com/outlook-vba/98468-macro-create-folder-pst-file.html)

Jen[_3_] December 30th 09 11:39 PM

Macro to create folder in PST file
 
I have leveraged a macro I found online to create a new folder
underneath the default Inbox, with a name entered by the user.

However, what I REALLY want is to create the new folder under a folder
that lives in another PST.

So instead of:

Mailbox
--Inbox
----New Folder
Users PST
--Project

I want it to be created as follows:

Mailbox
--Inbox

Users PST
--Project
----New Folder

Here is the code I have so far - can anyone help?

Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.MAPIFolder

Dim newProjectName As String
newProjectName = InputBox(Prompt:="You name please.", _
Title:="ENTER YOUR NAME", Default:="ENTRY")

Set myolApp = CreateObject("Outlook.Application")
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)


Set myNewFolder = myFolder.Folders.Add(newProjectName)

Dmitry Streblechenko December 31st 09 06:59 AM

Macro to create folder in PST file
 
Instead of using GetDefaultFolder method, use the Namespace.Folders
collection (which represents teh top level folders of all stores in the
profile) to find a folder named "Users PST", the use the MAPIFolder.Folders
collecton to access the subfolders.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Jen" wrote in message
...
I have leveraged a macro I found online to create a new folder
underneath the default Inbox, with a name entered by the user.

However, what I REALLY want is to create the new folder under a folder
that lives in another PST.

So instead of:

Mailbox
--Inbox
----New Folder
Users PST
--Project

I want it to be created as follows:

Mailbox
--Inbox

Users PST
--Project
----New Folder

Here is the code I have so far - can anyone help?

Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.MAPIFolder

Dim newProjectName As String
newProjectName = InputBox(Prompt:="You name please.", _
Title:="ENTER YOUR NAME", Default:="ENTRY")

Set myolApp = CreateObject("Outlook.Application")
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)


Set myNewFolder = myFolder.Folders.Add(newProjectName)




Jen[_3_] December 31st 09 04:10 PM

Macro to create folder in PST file
 
On Dec 30, 10:59*pm, "Dmitry Streblechenko"
wrote:
Instead of using GetDefaultFolder method, use the Namespace.Folders
collection (which represents teh top level folders of all stores in the
profile) to find a folder named "Users PST", the use the MAPIFolder.Folders
collecton to access the subfolders.

--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy *- Outlook, CDO
and MAPI Developer Tool
-"Jen" wrote in message

...

I have leveraged a macro I found online to create a new folder
underneath the default Inbox, with a name entered by the user.


However, what I REALLY want is to create the new folder under a folder
that lives in another PST.


So instead of:


Mailbox
--Inbox
----New Folder
Users PST
--Project


I want it to be created as follows:


Mailbox
--Inbox


Users PST
--Project
----New Folder


Here is the code I have so far - can anyone help?


* *Dim myolApp As Outlook.Application
* *Dim myNamespace As Outlook.NameSpace
* *Dim myFolder As Outlook.MAPIFolder
* *Dim myNewFolder As Outlook.MAPIFolder


* *Dim newProjectName As String
* *newProjectName = InputBox(Prompt:="You name please.", _
* * * * *Title:="ENTER YOUR NAME", Default:="ENTRY")


* *Set myolApp = CreateObject("Outlook.Application")
* *Set myNamespace = myolApp.GetNamespace("MAPI")
* *Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)


* *Set myNewFolder = myFolder.Folders.Add(newProjectName)


Would it be at all possible for you to give me an example? I tried
working with this, but just couldn't get anywhere!

Dmitry Streblechenko December 31st 09 04:16 PM

Macro to create folder in PST file
 
Off the op of my head, no error checking:

set RootFolder = myNamespace.Folders("Users PST")
set myFolder = RootFolder.Folders("Project")
Set myNewFolder = myFolder.Folders.Add(newProjectName)


--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Jen" wrote in message
...
On Dec 30, 10:59 pm, "Dmitry Streblechenko"
wrote:
Instead of using GetDefaultFolder method, use the Namespace.Folders
collection (which represents teh top level folders of all stores in the
profile) to find a folder named "Users PST", the use the
MAPIFolder.Folders
collecton to access the subfolders.

--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-"Jen" wrote in message

...

I have leveraged a macro I found online to create a new folder
underneath the default Inbox, with a name entered by the user.


However, what I REALLY want is to create the new folder under a folder
that lives in another PST.


So instead of:


Mailbox
--Inbox
----New Folder
Users PST
--Project


I want it to be created as follows:


Mailbox
--Inbox


Users PST
--Project
----New Folder


Here is the code I have so far - can anyone help?


Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.MAPIFolder


Dim newProjectName As String
newProjectName = InputBox(Prompt:="You name please.", _
Title:="ENTER YOUR NAME", Default:="ENTRY")


Set myolApp = CreateObject("Outlook.Application")
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)


Set myNewFolder = myFolder.Folders.Add(newProjectName)


Would it be at all possible for you to give me an example? I tried
working with this, but just couldn't get anywhere!



Jen[_3_] December 31st 09 04:29 PM

Macro to create folder in PST file
 
On Dec 31, 8:16*am, "Dmitry Streblechenko" wrote:
Off the op of my head, no error checking:

set RootFolder = myNamespace.Folders("Users PST")
set myFolder = RootFolder.Folders("Project")
*Set myNewFolder = myFolder.Folders.Add(newProjectName)

--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy *- Outlook, CDO
and MAPI Developer Tool
-"Jen" wrote in message

...
On Dec 30, 10:59 pm, "Dmitry Streblechenko"
wrote:



Instead of using GetDefaultFolder method, use the Namespace.Folders
collection (which represents teh top level folders of all stores in the
profile) to find a folder named "Users PST", the use the
MAPIFolder.Folders
collecton to access the subfolders.


--
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-"Jen" wrote in message


...


I have leveraged a macro I found online to create a new folder
underneath the default Inbox, with a name entered by the user.


However, what I REALLY want is to create the new folder under a folder
that lives in another PST.


So instead of:


Mailbox
--Inbox
----New Folder
Users PST
--Project


I want it to be created as follows:


Mailbox
--Inbox


Users PST
--Project
----New Folder


Here is the code I have so far - can anyone help?


Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Dim myNewFolder As Outlook.MAPIFolder


Dim newProjectName As String
newProjectName = InputBox(Prompt:="You name please.", _
Title:="ENTER YOUR NAME", Default:="ENTRY")


Set myolApp = CreateObject("Outlook.Application")
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)


Set myNewFolder = myFolder.Folders.Add(newProjectName)


Would it be at all possible for you to give me an example? *I tried
working with this, but just couldn't get anywhere!


That worked perfectly - thanks so much!


All times are GMT +1. The time now is 03:36 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com