CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: OutlookFolder

  1. #1
    Join Date
    Sep 2006
    Posts
    392

    Cool OutlookFolder

    Hi all,
    Good Evening to All,
    How can I retrive the outlook folders and their size without getting the anoying Outlook Security Prompt

    Thanks in Advance
    Dana
    VS 2005

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: OutlookFolder

    Need to create a Trusted ActiveX control, or Outlook won't like it.
    New changes since Windows SP2.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Sep 2006
    Posts
    392

    Re: OutlookFolder

    Dear David,
    Presently I am having this code with me.How can I improve on it
    Now How can I get the folder size of the Folders

    Code:
    Option Explicit
    'Micosoft CDO 1.21 Library
    'Micosoft Outlook 11.0 Object Library
    'Microsoft Scripting Runtime
    Dim colApp As Outlook.Application
    Dim colNameSpace As Outlook.NameSpace
    Dim myFolder, mySubFolder As Outlook.MAPIFolder
     Dim txt As TextStream
        Dim fso As New FileSystemObject
    Private Sub Command1_Click()
      On Error Resume Next
      Set colApp = CreateObject("Outlook.Application")
      Set colNameSpace = colApp.GetNamespace("MAPI")
        Set txt = fso.OpenTextFile("C:\1.txt", ForAppending, True)
        
        For Each myFolder In colNameSpace.Folders
          For Each mySubFolder In myFolder.Folders
            ''An error will be generated if .Description was left blank
            ''when the folder was created. On Error Resume Next should be used
            ''in which case .Description will = "" probable user created folder
            'If mySubFolder.Description = "" Or InStr(1, mySubFolder.Description, "inbox", vbTextCompare) <> 0 Then
            '  If mySubFolder.DefaultItemType = olMailItem Then 'is mail folder type unknown
                Call listsubfolder(mySubFolder)
               ' List1.AddItem mySubFolder.Name
                txt.WriteLine mySubFolder.Name
               Debug.Print mySubFolder.Name
                
            '  End If
            'End If
          Next
        Next
        txt.Close
      Set colNameSpace = Nothing
      colApp.Quit
      Set colApp = Nothing
    End Sub
    
    Private Sub listsubfolder(nfolder As Outlook.MAPIFolder)
       Dim sfolder As Outlook.MAPIFolder
        For Each sfolder In nfolder.Folders
         txt.WriteLine sfolder.Name
            Call listsubfolder(sfolder)
        Next
    End Sub
    VS 2005

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured