Announcement

Collapse
No announcement yet.

Public Folder Sort/Arrange by Date

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Public Folder Sort/Arrange by Date

    hi,

    Is there anyway of making a macro/script to run in outloook (or anywhere else if there's any other suggestions) to search a public folder and create subfolders of that and group together dates... i.e. september 08's emails all go into a sept 08 folder, aug 08 july 08 etc.
    This is my signature.

  • #2
    Re: Public Folder Sort/Arrange by Date

    Ok so I think I know what your saying...

    1. List all current public folders
    2. Then for every public folder, create subfolders for every month of 08
    3. Them move emails into matching subfolders by date

    Is that right?

    Comment


    • #3
      Re: Public Folder Sort/Arrange by Date

      I have nooo idea if this would be right...but maybe it's a starting point. I just put this together and I'm sure there are errors with this because I have no place to test it:

      Code:
      strComputerName = "serverName" 
      strFolderPath = "\folderPath\"
      
      strE2K3WMIQuery = "winmgmts://" & strComputerName &_
      "/root/MicrosoftExchangeV2"
      
      Set wmiService = GetObject(strE2K3WMIQuery)
      query = "Select * From Exchange_PublicFolder" & " Where Path='" & _
      strPubFolderPath & "'"
      
      Set targetFolder = wmiService.ExecQuery(query)
      
      intMonth = 1
      
      Do Until intMonth = 13
      
      	If intMonth = 1 then
      		strMonth = "Jan"
      	End If
      	If intMonth = 2 then
      		strMonth = "Feb"
      	End If
      	If intMonth = 3 then
      		strMonth = "Mar"
      	End If
      	If intMonth = 4 then
      		strMonth = "Apr"
      	End If
      	If intMonth = 5 then
      		strMonth = "May"
      	End If
      	If intMonth = 6 then
      		strMonth = "Jun"
      	End If
      	If intMonth = 7 then
      		strMonth = "Jul"
      	End If
      	If intMonth = 8 then
      		strMonth = "Aug"
      	End If
      	If intMonth = 9 then
      		strMonth = "Sep"
      	End If
      	If intMonth = 10 then
      		strMonth = "Oct"
      	End If
      	If intMonth = 11 then
      		strMonth = "Nov"
      	End If
      	If intMonth = 12 then
      		strMonth = "Dec"
      	End If
      
      strSubPath = targetFolder & "\" & strMonth & Year(date) & "\"
      
      Exchange_PublicFolder.AddReplica(strSubPath)
      
      intMonth = intMonth + 1
      Loop
      
      msgbox "Done!"
      
      WScript.Quit

      If you have a test network, give it a try. This will not move the emails into the subfolders, but it will create the subfolders....maybe.

      Comment


      • #4
        Re: Public Folder Sort/Arrange by Date

        We had someone else made a macro that'd move certain files with subject from personal sent items into a public folder but i'm not sure how it's doing that at the moment =(
        This is my signature.

        Comment


        • #5
          Re: Public Folder Sort/Arrange by Date

          Would you be able to post the macro? Most of the macro's can be converted to vbscript, i'd be interested to see that.

          Comment


          • #6
            Re: Public Folder Sort/Arrange by Date

            Code:
            VERSION 1.0 CLASS
            BEGIN
              MultiUse = -1  'True
            END
            Attribute VB_Name = "ThisOutlookSession"
            Attribute VB_GlobalNameSpace = False
            Attribute VB_Creatable = False
            Attribute VB_PredeclaredId = True
            Attribute VB_Exposed = True
            Sub MoveSentItems()
            ' Move Sent confirms to public folders
               
               
               
               Dim olns As Outlook.NameSpace
               Dim oConItems As Outlook.Items
               Dim iNumItems As Integer
               
            
               Set objNS = Application.GetNamespace("MAPI")
            ' Set Location to search (Sent Items)
               Set oinboxitems = objNS.GetDefaultFolder(olFolderSentMail).Items
            
            
            ' Define location to store sent mails
               Set objtargetfolder = objNS.Folders("Public Folders")
               Set objtargetfolder1 = objtargetfolder.Folders("All Public Folders")
               Set objtargetfolder2 = objtargetfolder1.Folders("Confirms")
               Set objtargetfolder3 = objtargetfolder2.Folders("Mail")
               Set objtargetfolderf = objtargetfolder2.Folders("Fax")
               
               
               
                
                iNumItems = oinboxitems.Count
                For i = iNumItems To 1 Step -1
                Set objcuritem = oinboxitems.Item(i)
                
                tst$ = objcuritem.Recipients(1)
                
                        
                If TypeName(objcuritem) = "MailItem" Then
                
                    If Left$(tst$, 3) = "fax" Then
                        objcuritem.Move objtargetfolderf
                    Else
                        If Left$(objcuritem.Subject, 18) = "Confirmation" Then
                            objcuritem.Move objtargetfolder3
                        
                    
                            End If
                        End If
                    End If
                Next i
                
             
            
               Set objInboxItems = Nothing
               Set objtargetfolder = Nothing
               Set objNS = Nothing
            
            End Sub
            This is my signature.

            Comment


            • #7
              Re: Public Folder Sort/Arrange by Date

              Ah ok that is different from what you described then, it's not sorting it by date. Nor is it moving messages from and existing public folder.

              Well anyway, you could use the same method to move the messages with my script, but I don't know how to check the date of each message so I would be stuck there.

              At least you got what you need...

              Comment


              • #8
                Re: Public Folder Sort/Arrange by Date

                ah yea, it takes it from mailbox sent items and moves to public folder...

                i need one that moves from public folder to another public folder - there's about 50+gb been stuffed in their and trying to access that folder freezes outlook for about 30 mins - makes it incredibly hard to sort out

                even if it could check the year it'd cut the load into 4 =P
                This is my signature.

                Comment

                Working...
                X