The top level folder of the new store is what you want to use in
RemoveStore.
I wouldn't bet that any newly added store has the highest index number
of the NameSpace.Folders collection, although so far in my experience
it always has. The sure fire way to make sure you get the correct
newly added store is to save all the StoreID's of all existing stores
before you add a new one. Then iterate the Namespace.Folders
collection and find the new StoreID that wasn't already saved. I
usually save things like that in a collection.
Rick Andrews said:
For that matter, how do I add a PST using AddStore and then later
remove the same PST using RemoveStore? AddStore takes a file path
whereas RemoveStore takes a MapiFolder object as a parameter. I can't
figure out how to get that MapiFolder object. It would be nice if I
could assume that when I call AddStore, the new store is added to the
end of the NameSpace's list of FolderObjects. i.e.,
Dim objOL As New Outlook.Application
Dim objName As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Set objName = objOL.GetNamespace("MAPI")
objName.AddStoreEx <path to PST>, olStoreUnicode
' Add the PST to the Profile
Set objFolder = objName.Folders.Item(objName.Folders.Count)
<<<<------- Can I do this? Will this be guarnteed to work in furture
versios of Outlook?