![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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) |
#2
|
|||
|
|||
![]()
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) |
#3
|
|||
|
|||
![]()
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! |
#4
|
|||
|
|||
![]()
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! |
#5
|
|||
|
|||
![]()
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! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
create Macro, Outlook 2007 - create is grayed out | Dave Horne[_2_] | Outlook - General Queries | 2 | November 4th 07 09:45 AM |
Macro to extract subject and sender name of messages in folder to Excel file | bony_tony | Outlook and VBA | 0 | March 7th 07 01:16 AM |
How do I create a macro to email a file | Roger | Outlook and VBA | 1 | October 24th 06 06:20 PM |
create macro to show file size in outlook | john mcmichael | Outlook and VBA | 3 | May 2nd 06 09:55 PM |