Excel Access to .PST File in Outlook

kgkev

Well-known Member
Joined
Jun 24, 2008
Messages
1,291
Office Version
  1. 365
Platform
  1. Windows
I have used VBA to download all email address I have sent and received emails from in my inbox.

Now I want to do the same for my .PST archive file.

My Current code is.
Rich (BB code):
Sub GetFromInbox()
Application.ScreenUpdating = False

    Dim olApp As Outlook.Application
    Dim olNs As NameSpace
    Dim Fldr As MAPIFolder
    Dim olMail As MailItem
    Dim i As Integer
    Dim x As Integer
    Dim y As Integer
    Dim internalcount As Integer
    

    Set olApp = New Outlook.Application
    Set olNs = olApp.GetNamespace("MAPI")
    Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
    Set Fldr = Fldr.Folders("2011").Folders("inbox")
    UserForm1.Show False
    
    i = 1
    x = 1
    
    Sheets("New").Cells.ClearContents
    y = Fldr.Items.Count
    
    For Each olMail In Fldr.Items
        UserForm1.TextBox1.Value = x & "  //  " & y
        UserForm1.Repaint
        
            Sheets("New").Cells(i, 1).Value = olMail.SenderName
            Sheets("New").Cells(i, 2).Value = olMail.SenderEmailAddress
            i = i + 1
        
            x = x + 1
        On Error Resume Next
    Next olMail
    UserForm1.Hide
    
    Set Fldr = Nothing
    Set olNs = Nothing
    Set olApp = Nothing

End Sub


how do I set the folder to my .pst file

.PST Folder name is

2010/Inbox

Any advise would be appreciated.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,224,609
Messages
6,179,877
Members
452,949
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top