Help!

How do I delete Search folders?

 
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Program Add-Ins RSS
Next:  Accessing the forms in personal forms  
Author Message
Mark B
External


Since: Apr 01, 2009
Posts: 15



PostPosted: Fri Feb 26, 2010 4:10 pm    Post subject: How do I delete Search folders?
Archived from groups: microsoft>public>outlook>program_addins (more info?)


OL2007, VSTO

On Addin exit, I am trying to delete all search folders I previously
programmatically created so that next time OnAddin startup, I can recreate
them cleanly (in order to try and workaround unexpected behavior such as
folder italicization after 1 or 2 days).

When I walk through the code I see an exception generated at
existingFolder.Delete() stopping the delete:

"Cannot 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."

Any ideas on why this would be happening and how to remedy it?

public void Remove()
{
if (this.folderEntryId != null)
{
Outlook.Application olApp;
olApp = Globals.ThisAddIn.Application;

try
{
Outlook.MAPIFolder existingFolder =
olApp.GetNamespace("MAPI").GetFolderFromID(
this.folderEntryId, Type.Missing);

if (existingFolder != null)
existingFolder.Delete();
}
catch (Exception)
{
}
}
}
Back to top
Ken Slovak - [MVP - Outlo
External


Since: Oct 17, 2003
Posts: 3405



PostPosted: Mon Mar 01, 2010 9:01 am    Post subject: Re: How do I delete Search folders? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Does the same code run without errors if you run it some other place in your
addin? If so try handling the Explorer.Close() event and if there are no
other Explorers and no open Inspectors then call your remove code then. See
if that works.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mark B" wrote in message

> OL2007, VSTO
>
> On Addin exit, I am trying to delete all search folders I previously
> programmatically created so that next time OnAddin startup, I can recreate
> them cleanly (in order to try and workaround unexpected behavior such as
> folder italicization after 1 or 2 days).
>
> When I walk through the code I see an exception generated at
> existingFolder.Delete() stopping the delete:
>
> "Cannot 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."
>
> Any ideas on why this would be happening and how to remedy it?
>
> public void Remove()
> {
> if (this.folderEntryId != null)
> {
> Outlook.Application olApp;
> olApp = Globals.ThisAddIn.Application;
>
> try
> {
> Outlook.MAPIFolder existingFolder =
> olApp.GetNamespace("MAPI").GetFolderFromID(
> this.folderEntryId, Type.Missing);
>
> if (existingFolder != null)
> existingFolder.Delete();
> }
> catch (Exception)
> {
> }
> }
> }
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Program Add-Ins All times are: Eastern Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum