Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Subfolder in Outlook...

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,63420
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Subfolder in Outlook...
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Subfolder in Outlook... - 8/13/2008 4:31:38 AM   
  patgenn123

 

Posts: 37
Score: 0
Joined: 1/14/2008
Status: offline
Hello all!

I am having the toughest time trying to create a subfolder that is NOT a subfolder of the Inbox folder.

The microsoft website http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept07/hey0926.mspx describes how to create a subfolder to Inbox AND a folder on the same level of Inbox, but not a subfolder of a different folder other than the Inbox folder.

Can someone point me in the right direction? 

-P 
 
 
Post #: 1
 
 RE: Subfolder in Outlook... - 8/13/2008 6:17:03 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
Well I had some issues with this, but you're welcome to try this.... Try some of the other values and see if your results are similar to mine.


      

< Message edited by Rischip -- 8/13/2008 6:18:39 AM >


_____________________________

Rischip
Author of - The Grim Linker

(in reply to patgenn123)
 
 
Post #: 2
 
 RE: Subfolder in Outlook... - 8/13/2008 10:17:10 AM   
  patgenn123

 

Posts: 37
Score: 0
Joined: 1/14/2008
Status: offline
Thanks Rischip!

I tried it and haven't modified it yet ,  but it looks like it's very good. 

If I could ask another question.  Before I do,  I want to say I don't want to "mooch" off of anyone.  i would like to learn VBscript a little at a time.

That being said,  could you direct me to finding this answer: 



I am trying to create a script that loops through the outlook folder and copies the names of the folders in a text file.   Is there a way to do this?
 
Thanks!
 
-P

(in reply to patgenn123)
 
 
Post #: 3
 
 RE: Subfolder in Outlook... - 8/13/2008 5:55:08 PM   
  patgenn123

 

Posts: 37
Score: 0
Joined: 1/14/2008
Status: offline
OK!

Disregard the last post.

One Question. 

How do you create a subfolder under a subfolder?

From your example:

My New Folder is the TOP folder
More Scripts is the subfolder

How do I create a subfolder to the Subfolder "More Scripts" called VBScripts?

Thanks!

Pat

(in reply to patgenn123)
 
 
Post #: 4
 
 RE: Subfolder in Outlook... - 8/14/2008 12:38:44 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
Basically in this code you SET the object reference "Namespace" to the folder name at the level which you want to modify.


Set objMailbox = objNamespace.Folders(strTopLevelFolderName) ' In the code this is the MAIN MAILBOX level

Set objNewFolder = objMailbox.Folders.Add(newFolderName) 'We add a folder under MAIN MAILBOX with the name in the variable newFolderName

Set objNewSubFolderNS = objMailbox.Folders(newFolderName) 'Then we set our "NameSpace" to the level of the folder we just created

Set objNewSubFolder = objNewSubFolderNS.Folders.Add(newSubFolderName) 'At the "newFolderName" Level, we can add another sub folder and so on.....

Set NameSpace (foldername) then Folders.Add

_____________________________

Rischip
Author of - The Grim Linker

(in reply to patgenn123)
 
 
Post #: 5
 
 RE: Subfolder in Outlook... - 8/17/2008 2:53:38 PM   
  patgenn123

 

Posts: 37
Score: 0
Joined: 1/14/2008
Status: offline
Hello all..

I have a problem that I need help on.

I figured out the way to add a subfolder without the "prompt" telling me that the folder(s) already exists.

It goes like this:

Const olFolderInbox = 6
Const newFolderName = " My New Folder" 'I don't know why but on my installation
                                      'Outlook 2003 SP3 on XP SP2
                                      'This value will create under the inbox with certain values
                                      'under the MAIN MAILBOX with other values
                                      '"Scripts Received" = Inbox
                                      '"""Scripts Received""" = Mailbox
                                      '" Scripts Received " = MailBox
                                      '"(Scripts Received)" = MailBox
                                      '"My New Folder" = Inbox
                                      '" My New Folder" = MailBox
                                     
Const newSubFolderName = "More Scripts"
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(olFolderInbox)

'Set objNewFolder = objFolder.Folders.Add("Scripts Received")
strTopLevelFolderName = objFolder.Parent
Set objMailbox = objNamespace.Folders(strTopLevelFolderName)


Set objNewSubFolderNS = objMailbox.Folders(newFolderName)

Set objNewSubFolder = objNewSubFolderNS.Folders.Add(newSubFolderName)


Just delete the third last line and if the "Top Level folder" already exists, then it will just add the subfolder even though the toplevel folder is already there. Rischip's example assumes that neither the "toplevel folder" exists nor the subfolder.
 
I was wondering if someone could just show me Rishchip's example with script. I tried and it's not working for me.  How do you create multiple subfolders to an existing subfolder that could go down 3,4,5 etc. levels?

I am sure it's simple, but I am new at this and have a hard time grasping this......

Thanks!

-P

(in reply to Rischip)
 
 
Post #: 6
 
 RE: Subfolder in Outlook... - 8/18/2008 1:24:34 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
Which part are you having trouble with... This was example code based on your request, and it does work for me. What is your configuration?

quote:

I am having the toughest time trying to create a subfolder that is NOT a subfolder of the Inbox folder.

The microsoft website http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept07/hey0926.mspx describes how to create a subfolder to Inbox AND a folder on the same level of Inbox, but not a subfolder of a different folder other than the Inbox folder.


The code I provided does that. I also explained that in order to create a subfolder that you need to set the namespace to the folder where you want to create the sub, then use the .Folders.Add method. Which part do you not understand?

< Message edited by Rischip -- 8/18/2008 2:35:54 AM >


_____________________________

Rischip
Author of - The Grim Linker

(in reply to patgenn123)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Subfolder in Outlook... Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts