A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How do I delete Search folders?



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 26th 10, 09:33 PM posted to microsoft.public.outlook.program_addins
Mark B[_2_]
external usenet poster
 
Posts: 93
Default How do I delete Search folders?

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)
{
}
}
}

Ads
  #2  
Old March 1st 10, 03:01 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default How do I delete Search folders?

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)
{
}
}
}


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Instant Search, Advanced Find, Search Folders, and Windows Desktop [email protected] Outlook - General Queries 2 October 31st 08 07:37 PM
Outlook 2003 - Search folders - adding criteria to an old mail search? Dustin Emhart Outlook - General Queries 0 December 20th 06 03:39 PM
What are "Search Folders.dbx" and is it ok/safe to delete them? sheana Outlook Express 3 November 18th 06 01:31 AM
Hide/Delete Deleted Items & Search Folders Folders in Outlook 2003 jpspringall Outlook and VBA 1 April 24th 06 03:51 PM
How to delete Suggested Matches from "Search for Files and Folders" [email protected] Outlook - General Queries 0 January 9th 06 02:58 AM


All times are GMT +1. The time now is 01:14 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.