R
RichW
I am using the Office XP PIA to programmatically work with OOM. One
of the things I want to do is clean a messagestore of any top level
folders aside from the user "Mailbox -" hierarchy and the Public
Folders.
If I am in Outlook I can right-click on the folder and select Close
<Folder name>. It looked like I could accomplish the same thing with
MAPIFolder.Delete(). However, when I attempt to do this the following
exception is raised:
"Unable to delete this folder. Right-click the folder, and then click
Properties to check your permissions for the folder. See the folder
owner or your administrator to change your permissions."
Does anyone have any wisdom to offer on this?
Here is the code snippet:
private string CleanFolders(Microsoft.Office.Interop.Outlook.NameSpace
oNS)
{
// This method will delet any folders that have been mistakenl left
from prior jobs.
try
{
foreach (Microsoft.Office.Interop.Outlook.MAPIFolder oneStore in
oNS.Folders)
{
string FolderName = oneStore.Name;
if (FolderName == "Public Folders" ||
String.Compare(FolderName.Substring(0,10), "Mailbox - ") == 0)
continue;
else
oneStore.Delete();
}
}
catch (System.Exception ex)
{
return "Error going through Cleanfolders: " + ex.Message;
}
return "Success";
}
Best,
- Rich
of the things I want to do is clean a messagestore of any top level
folders aside from the user "Mailbox -" hierarchy and the Public
Folders.
If I am in Outlook I can right-click on the folder and select Close
<Folder name>. It looked like I could accomplish the same thing with
MAPIFolder.Delete(). However, when I attempt to do this the following
exception is raised:
"Unable to delete this folder. Right-click the folder, and then click
Properties to check your permissions for the folder. See the folder
owner or your administrator to change your permissions."
Does anyone have any wisdom to offer on this?
Here is the code snippet:
private string CleanFolders(Microsoft.Office.Interop.Outlook.NameSpace
oNS)
{
// This method will delet any folders that have been mistakenl left
from prior jobs.
try
{
foreach (Microsoft.Office.Interop.Outlook.MAPIFolder oneStore in
oNS.Folders)
{
string FolderName = oneStore.Name;
if (FolderName == "Public Folders" ||
String.Compare(FolderName.Substring(0,10), "Mailbox - ") == 0)
continue;
else
oneStore.Delete();
}
}
catch (System.Exception ex)
{
return "Error going through Cleanfolders: " + ex.Message;
}
return "Success";
}
Best,
- Rich