none
location of outlook pst and ost files RRS feed

  • Question

  • Is there any way to get the location of the email files .pst and .ost while in Visual Studio using visual basic ???

    Thanks

    cyberal

    Friday, August 11, 2017 7:07 PM

All replies

  • Depending on the operating system version it can be in a different location,see the following.

    Use Environment.SpecialFolder to locate based on the link above.

    So depending on the OS version and the version of Outlook you would calculate the base folder and use something like this. For me, I have four .ost files, one for each email address running Office 2013 on Windows 7 thus by the link above I check as follows.

    If IO.File.Exists(IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\Outlook", "KP@comcast.net.ost")) Then
        Console.WriteLine("yes")
    End If


    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

    Friday, August 11, 2017 8:50 PM
    Moderator
  • First, thanks so much for your reply Karen. What I was looking for is a command or commands that would allow me to to look for a file while I am in Visual Studio and using Visual Basic.  ie  provide a file name, in my case outlook.pst or archive.pst  or myemail@charter.net.ost and have the routine search for and return the full path to the location of any of these files on my PC.  Much the same way one can use File Explorer to search for files, except I want to do this while in Visual Studio and using Visual Basic.

    Maybe it is not possible. That would be an acceptable answer also

    Thanks much

    cyberal

    Saturday, August 12, 2017 11:22 PM
  • I've never found a need for this myself but can offer a simplistic approach using a BackGroundWorker component that does not fully met your needs yet robust enough for you to learn from it, modify to met your needs.

    Caveats, there are assertions to skip folders that you don't have read access too and this is one of several ways of doing this. It also has a method to cancel the search that is currently in progress.

    There are other methods to hook into the indexes of Windows uses for searching yet I would not advise this method as I've seen it have issues.

    Full source is here

    https://1drv.ms/u/s!AtGAgKKpqdWjiBBELwgxzo8pAZEo


    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

    Sunday, August 13, 2017 12:05 AM
    Moderator
  • This may help - You must add a reference to Microsoft.Office.Interop.Outlook in the Project Properties.

    Option Strict On
    Imports Microsoft.Office.Interop
    Public Class Form1
        Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
            Dim OutlookApp As Outlook.Application = New Outlook.Application
    
            For Each vStore As Outlook.Store In OutlookApp.Session.Stores
                TextBox1.AppendText(vStore.DisplayName & " - " & vStore.FilePath & vbNewLine)
            Next
            OutlookApp.Quit()
            OutlookApp = Nothing
        End Sub
    End Class


    Wednesday, August 16, 2017 2:01 AM
  • Nothing built into .NET but you can use the Redemption component:

    http://www.dimastr.com/redemption/rdostore.htm#RDOPstStore


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Wednesday, August 16, 2017 4:04 PM