Finding a .pst file I have just renamed

C

Carol Chisholm

I'm building a set of quarterly archive folders.
I create new stored then rename them.
Since they are created without inboxes, I then have to add an inbox.
However I can't find my newly renamed .pst file until the executing
code is stopped and restarted.

Any ideas: does AddStore accept a name argument? Or how can I refresh
the folderlist in the current namespace?

.....

for i = 1 to n
olSession.AddStore sArchPath & sArchFold(i)

If olSession.Folders.GetLast.Name = "Personal Folders" Then
olSession.Folders.GetLast.Name = sArchFold(i)
End If

'look for inbox, if it don't exist, create
strTempFolderRoot = sArchFold(i)
strTempFolder = sArchFold(i) & "\Inbox"

Set olTempFolderRoot = GetFolder(strTempFolderRoot)
Set olTempFolder = GetFolder(strTempFolder)

If olTempFolder Is Nothing Then
olTempFolderRoot.Folders.Add ("Inbox")
End If
.....
Function GetFolder(strFolderPath As String) As Outlook.MAPIFolder
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim arrFolders() As String
Dim i As Long

On Error Resume Next

strFolderPath = Replace(strFolderPath, "/", "\")
arrFolders() = Split(strFolderPath, "\")
Set objFolder = olSession.Folders.Item(arrFolders(0))

If Not objFolder Is Nothing Then
For i = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(i))
If objFolder Is Nothing Then
Exit For
End If
Next
End If

Set GetFolder = objFolder
Set colFolders = Nothing

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top