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

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Posts
    93

    List folders in outlook

    I am writing code to redirect mails from perticular EmailAddress.

    For that i am giving user a form in which all the folders in outlook will be listed.

    I am not getting the code to do this.

    I can do this if i want to list folders from perticular folder like inbox by this :
    Code:
    Set myOlApp = CreateObject("Outlook.Application")
            Set name = myOlApp.GetNamespace("MAPI")
            Set fldFolder = name.Folders("olinbox")
            'For Each prfolder In fldFolder
            
            Set objApp = CreateObject("Outlook.Application")
            Set objNS = objApp.GetNamespace("MAPI")
        
        Call GetFolderInfo(fldFolder)
    GetFolderInfo is listing folders in fldfolder.

    But i want to check for all folders in outlook.(like folders in outbox, inbox....)

    How can i list them?

  2. #2
    Join Date
    Oct 2003
    Location
    Timisoara, Romania
    Posts
    460

    Re: List folders in outlook

    Hi v_gyku,
    It is me again So check out the attached code. It's a very usefull application and all my coleagues thanked me three times for creating this It is saving all attachments from all e-mails in selected directory. It creates a directory structure on the disk exactly like the one in your e-mail account. Also check out the filters
    Tell me you opinion about it
    Attached Files Attached Files
    You liked it? Please show your gratitude and rate it!

    There is no 'patch' for stupidity.

  3. #3
    Join Date
    Aug 2005
    Posts
    93

    Re: List folders in outlook

    Code:
    Private Sub CommandButton1_Click() 
        Dim NS As NameSpace 
        Set NS = Application.GetNamespace("MAPI") 
        listSubFolders NS.Folders(1) 
    End Sub 
    Private Sub listSubFolders(f As MAPIFolder, Optional i As Integer) 
        Dim x As MAPIFolder 
        For Each x In f.Folders 
             ' Optional test for email type folders only
             ' If x.DefaultItemType = olMailItem Then
            listFolders.AddItem x.EntryID 
            listFolders.Column(1, listFolders.ListCount - 1) = String(i, "-") & x.Name 
            If x.Folders.count > 0 Then listSubFolders x, i + 1 
             ' End If
        Next 
    End Sub
    I have this code , but its giving me error on this lin :

    Code:
    listFolders.Column(1, listFolders.ListCount - 1) = String(i, "-") & x.Name
    method or data member not found.

    Thanks!

  4. #4
    Join Date
    May 2005
    Location
    Sterling Heights, MI
    Posts
    74

    Re: List folders in outlook

    Quote Originally Posted by vma
    Hi v_gyku,
    It is me again So check out the attached code. It's a very usefull application and all my coleagues thanked me three times for creating this It is saving all attachments from all e-mails in selected directory. It creates a directory structure on the disk exactly like the one in your e-mail account. Also check out the filters
    Tell me you opinion about it
    Very cool!

  5. #5
    Join Date
    Aug 2005
    Posts
    93

    Re: List folders in outlook

    Hello Everyone !

    I am able to take all folders in a listbox.

    If i select a folder which is not user cretaed then my code works fine.
    But if try to route a message to a user created folder then it fails.
    gives error: The operation failed. Object could not be found.

    Code:
     final1 = txtBrowse1.Text
        Set myNameSpace = myOlApp.GetNamespace("MAPI")
        Set myOlApp = CreateObject("Outlook.Application")
        Set fldFolder1 = myNameSpace.Folders(1) 
        Set myInbox = myNameSpace.Folders(1) 
        If final1 = "" Then
        txtBrowse1.SetFocus
        Else
        Dim eidctr, post As Integer
        eidctr = eid1.Count
        post = 1
        While eidctr > 0
        
        MsgBox (fldFolder1.Folders.Item(eid1.Item(post)))
        
             
             Set myDestFolder = fldFolder1.Folders.Item(eid1.Item(post))
            eidctr = eidctr - 1
            post = post + 1
        Wend
        End If
    I am taking entry id of each folder in eid. iTs a collection.

  6. #6
    Join Date
    Aug 2005
    Posts
    93

    Re: List folders in outlook

    I am listing all folders in outlook.
    User will select any folder from a listbox.
    User will select an email id from another listbox.
    When he clicks on command button all the messages from selected email id will be shifted to selected folder.

    If i am selecting a folder like inbox, outbox,drafts, junk email....(which r not user cretaed.) then my code is working fine.

    But if i select user selected folder it gives me error: The operation failed. Object could not be found.

  7. #7
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    Re: List folders in outlook

    I Know all of these stuff.but not in VB in VC++ i can do.So if you wann idea how to do.i can tell .How to implement it's upto you.So exactly what the question and what is the issue here Please let me know.

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