MAPIFolder.Delete() vs. RDOFolder.Delete()

G

Guest

I have a plugin which creates a folder that I only want to exist during the
time Outlook is running, so I've been experimenting with various ways to
delete this folder. Couple questions,

1) Using MAPIFolder.Delete() seems to work every time, but the folder ends
up in the Deleted Items folder...is there a way through the OOM to bypass
Deleted Items when deleting a folder?

2) Using Redemption's RDOFolder.Delete() is kind of hit or miss. What I've
noticed is that sometimes, right after creating the folder, I can delete it,
but most often when caling this method, I get a MAPI_E_EXTENDED_ERROR
(ErrorCode=-2147221223, Message="Error in IMAPIFolder::DeleteFolder:
MAPI_E_EXTENDED_ERROR") . If I keep trying to delete this folder (i have a
test button calling the delete method), it will eventually work after about a
minute or so. Could this be the result of some kind of Exchange
synchronization holding onto the folder?

What is the best way to delete a folder? sample code follows for the
RDODelete call I'm using:

public bool DeleteArchiveSearchFolder(string sArchiveFolder)
{
if (!_IsValid() || sArchiveFolder == null)
return false;

// Have to find out if the thing is already here
RDOFolders fIPMFolders = m_DefaultMsgStore.IPMRootFolder.Folders;

foreach (RDOFolder f in fIPMFolders)
{
if (f.Name.Equals(sArchiveFolder,
StringComparison.CurrentCultureIgnoreCase))
{
f.Delete();
return true;
}
}

return false;
}
 
K

Ken Slovak - [MVP - Outlook]

1. No. It will always go to Deleted Items.

2. Try to just get the folder.EntryID in the loop, then release all those
objects, then try to get the folder back using RDOSession.GetFolderFromID
using the EntryID and delete it then. See if that works.
 
D

Dmitry Streblechenko

1. You can delete it twice - second tiem in teh Deleted Items folder.
2. Cached provider sometimes complains that it is still busy synching to the
server, so it cannot delete the folder before it is done.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

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