Results 1 to 17 of 17

Thread: Simple move email to different folder

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Contributor
    Joined
    Jul 2009
    Posts
    156
    Location
    Thanks JP but I need the folders from a Personal folder PST file and I am not sure how to code it with the following path:

    P:\PST\TestDataFile\TestDataFileNAME\TestDataFileNAMEfolder

    I guess I am not clear on what would change in the code you posted - see below for the specific line I am referring to. For instance would (olFolderInbox) remain the same and if now what would it change to ? I may be able to get there with the following folders once I get started with the intial part of the code.

    Set fldr = Outlook.Session.GetDefaultFolder(olFolderInbox).Folders("My Messages").Folders("My Folder")

    Thanks for the help. Any advice on this ?




    Last edited by Aussiebear; 04-02-2025 at 05:19 AM.

  2. #2
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    It doesn't matter that it's a personal PST, what matters is that it's open and viewable in the Navigation Pane.

    I can access my default Inbox using

    Outlook.Session.GetDefaultFolder(olFolderInbox)
    or

    Outlook.Session.Folders("Mailbox - JIMMY PENA").Folders("Inbox")
    I have a local PST file on my computer. The top level is called "Archive Folders" so to access THAT Inbox the code would be

    Outlook.Session.Folders("Archive Folders").Folders("Inbox")
    Are you with me so far?

    If the folder was in my local PST, and it was two levels below the Inbox like this:

    Inbox --\
    Level 1 --\
    Level 2

    Then I would reach it like this:

    Outlook.Session.Folders("Archive Folders").Folders("Inbox").Folders("Level 1").Folders("Level 2")
    The folder doesn't have to be related to the Inbox. If I had another mail folder that was on the same level as the Inbox, the code would be

    Outlook.Session.Folders("Archive Folders").Folders("My Other Mail Folder")
    Now you need to apply that logic to your particular situation.

    One thing you do have to change is in Outlook 2007, the MAPIFolder Object no longer exists. You need to declare MAPIFolder Objects as Folder Objects instead. Otherwise the code should be the same (but always keep the Outlook 2007 Object Model Reference handy.


    Quote Originally Posted by bdsii
    Thanks JP but I need the folders from a Personal folder PST file and I am not sure how to code it with the following path:

    P:\PST\TestDataFile\TestDataFileNAME\TestDataFileNAMEfolder

    I guess I am not clear on what would change in the code you posted - see below for the specific line I am referring to. For instance would (olFolderInbox) remain the same and if now what would it change to ? I may be able to get there with the following folders once I get started with the intial part of the code.

    Set fldr = Outlook.Session.GetDefaultFolder(olFolderInbox).Folders("My Messages").Folders("My Folder")

    Thanks for the help. Any advice on this ?
    Last edited by Aussiebear; 04-02-2025 at 05:20 AM.
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •