none
Allow user to select Outlook folder to search RRS feed

  • Question

  • So I am working on a project to retrieve attachments from outlook, then import the contents of said attachment into excel.  To make the code more robust, I thought it would be good to allow them to select the folder to search incase they store the emails into a different folder. Any ideas on how to do this?

    Thank you,

    Chris

    Monday, August 14, 2017 12:35 AM

All replies

  • See my reply below which has a link describing how versions of Outlook can have different locations for emails and this is coupled with different versions of windows.

    https://social.msdn.microsoft.com/Forums/en-US/c724e4b3-dbf1-41b8-9bec-dc3a8bddd907/location-of-outlook-pst-and-ost-files?forum=vbgeneral


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, August 14, 2017 6:56 PM
  • Hello Chris,

    Looks like you are interested in the PickFolder method of the Namespace class which displays the Pick Folder dialog box. The Pick Folder dialog box is a modal dialog box which means that code execution will not continue until the user either selects a folder or cancels the dialog box. The returned value is a Folder object that represents the folder that the user selects in the dialog box, or Nothing if the dialog box is canceled by the user. For example, a VBA macro sample code:

    Sub FolderPick()
    
        Dim objNS As NameSpace
        Dim objFolder As folder
    
        Set objNS = Application.GetNamespace("MAPI")
        Set objFolder = objNS.PickFolder
    
        If TypeName(objFolder) <> "Nothing" Then
            Debug.Print vbCr & " objFolder: " & objFolder
        Else
            Debug.Print vbCr & "Cancel"
        End If
    
        Set objFolder = Nothing
        Set objNS = Nothing
    
    End Sub


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Tuesday, August 15, 2017 10:30 AM
  • Hello Chris,

    Does code shared by Eugene work for you?

    If your issue persists, please free feel to let me know.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 25, 2017 3:27 AM
    Moderator