Delete without going to deleted items folder ! 
Author Message
 Delete without going to deleted items folder !

I create a folder under the Outlook Today - [Personal Folders] folder using
the outlook object model, when my addin terminates I want to delete the
folder I created.  The problem I have is that the folder gets put into the
deleted items folder when I call the method Delete on it.  Is there any way
to force it not to put the folder into the deleted items, but just delete
it.



Sun, 22 Jun 2003 21:02:08 GMT  
 Delete without going to deleted items folder !
Try getting the folder using CDO and use the CDO Delete method.

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


Quote:
> I create a folder under the Outlook Today - [Personal Folders]
folder using
> the outlook object model, when my addin terminates I want to delete
the
> folder I created.  The problem I have is that the folder gets put
into the
> deleted items folder when I call the method Delete on it.  Is there
any way
> to force it not to put the folder into the deleted items, but just
delete
> it.



Sun, 22 Jun 2003 21:52:47 GMT  
 Delete without going to deleted items folder !
Hi Huw,

I just asked a very similar question to this! (I am using the object model
from C++)

However I am deleting appointments, whereas you are deleting a folder.

I have though of an approach that does not work for me but *might* work for
you - I have not tried it though.

As we know,  if you go into Outlook and delete any appointment or folder
from deleted items then it gets properly deleted

So I figured that I could call Delete on the item twice, once to *move* it
to deleted items, and again to delete it properly.

I maintain a note of the ID of the item, delete it, then attempt to retrieve
it again using the ID.

The key thing is that for Appointments, the attempt to retrieve it (using
GetItemFromID) fails.

However doing the same thing on a folder (but using GetFolderFromID instead)
seems to work (in that it retrieves the folder).

So now you can try calling delete on the folder you just retrieved.

It might work!

Tim


Quote:

> I create a folder under the Outlook Today - [Personal Folders] folder
using
> the outlook object model, when my addin terminates I want to delete the
> folder I created.  The problem I have is that the folder gets put into the
> deleted items folder when I call the method Delete on it.  Is there any
way
> to force it not to put the folder into the deleted items, but just delete
> it.



Sun, 22 Jun 2003 21:36:14 GMT  
 Delete without going to deleted items folder !
CDO is not installed on the machine.

Any other way ?



Quote:
> Try getting the folder using CDO and use the CDO Delete method.

> --
> Ken Slovak
> [MVP - Outlook]
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
> Appendices, Sams



> > I create a folder under the Outlook Today - [Personal Folders]
> folder using
> > the outlook object model, when my addin terminates I want to delete
> the
> > folder I created.  The problem I have is that the folder gets put
> into the
> > deleted items folder when I call the method Delete on it.  Is there
> any way
> > to force it not to put the folder into the deleted items, but just
> delete
> > it.



Sun, 22 Jun 2003 22:16:45 GMT  
 Delete without going to deleted items folder !
CDO is not installed on the machine.

Any other way ?



Quote:
> Try getting the folder using CDO and use the CDO Delete method.

> --
> Ken Slovak
> [MVP - Outlook]
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
> Appendices, Sams



> > I create a folder under the Outlook Today - [Personal Folders]
> folder using
> > the outlook object model, when my addin terminates I want to delete
> the
> > folder I created.  The problem I have is that the folder gets put
> into the
> > deleted items folder when I call the method Delete on it.  Is there
> any way
> > to force it not to put the folder into the deleted items, but just
> delete
> > it.



Sun, 22 Jun 2003 22:16:45 GMT  
 Delete without going to deleted items folder !
Thanks, I'll give it a go.


Quote:
> Hi Huw,

> I just asked a very similar question to this! (I am using the object model
> from C++)

> However I am deleting appointments, whereas you are deleting a folder.

> I have though of an approach that does not work for me but *might* work
for
> you - I have not tried it though.

> As we know,  if you go into Outlook and delete any appointment or folder
> from deleted items then it gets properly deleted

> So I figured that I could call Delete on the item twice, once to *move* it
> to deleted items, and again to delete it properly.

> I maintain a note of the ID of the item, delete it, then attempt to
retrieve
> it again using the ID.

> The key thing is that for Appointments, the attempt to retrieve it (using
> GetItemFromID) fails.

> However doing the same thing on a folder (but using GetFolderFromID
instead)
> seems to work (in that it retrieves the folder).

> So now you can try calling delete on the folder you just retrieved.

> It might work!

> Tim



> > I create a folder under the Outlook Today - [Personal Folders] folder
> using
> > the outlook object model, when my addin terminates I want to delete the
> > folder I created.  The problem I have is that the folder gets put into
the
> > deleted items folder when I call the method Delete on it.  Is there any
> way
> > to force it not to put the folder into the deleted items, but just
delete
> > it.



Sun, 22 Jun 2003 23:44:02 GMT  
 Delete without going to deleted items folder !
Extended MAPI. You are using VC++, right?
1. get EntryID of the message.
2. convert it to binary (each two ASCII bytes - > 1 byte)
3. Do the same for the parent folder's EntryID and StoreID
4. call MAPILogonEx(), do *not* set MAPI_NEW_SESSION  flag, you will get back
the same session Outlook is using
5. Call IMAPISession.OpenMsgStore() using EntryID of the store from #3. You will
get back IMsgStore.
5. call IMsgStore.OpenEntry() on the folder id from #3 - get back IMAPIFolder.
6. Make sure you Release()'ed the message.
7. call IMAPIFolder.DeleteMessages() specifying the message entry id

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


Quote:
> CDO is not installed on the machine.

> Any other way ?



> > Try getting the folder using CDO and use the CDO Delete method.

> > --
> > Ken Slovak
> > [MVP - Outlook]
> > Lead Author, Professional Outlook 2000 Programming, Wrox Press
> > Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
> > Appendices, Sams



> > > I create a folder under the Outlook Today - [Personal Folders]
> > folder using
> > > the outlook object model, when my addin terminates I want to delete
> > the
> > > folder I created.  The problem I have is that the folder gets put
> > into the
> > > deleted items folder when I call the method Delete on it.  Is there
> > any way
> > > to force it not to put the folder into the deleted items, but just
> > delete
> > > it.



Mon, 23 Jun 2003 01:10:03 GMT  
 Delete without going to deleted items folder !
No, I'm developing a Com Add-In in VB.


Quote:
> Extended MAPI. You are using VC++, right?
> 1. get EntryID of the message.
> 2. convert it to binary (each two ASCII bytes - > 1 byte)
> 3. Do the same for the parent folder's EntryID and StoreID
> 4. call MAPILogonEx(), do *not* set MAPI_NEW_SESSION  flag, you will get
back
> the same session Outlook is using
> 5. Call IMAPISession.OpenMsgStore() using EntryID of the store from #3.
You will
> get back IMsgStore.
> 5. call IMsgStore.OpenEntry() on the folder id from #3 - get back
IMAPIFolder.
> 6. Make sure you Release()'ed the message.
> 7. call IMAPIFolder.DeleteMessages() specifying the message entry id

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



> > CDO is not installed on the machine.

> > Any other way ?


message

> > > Try getting the folder using CDO and use the CDO Delete method.

> > > --
> > > Ken Slovak
> > > [MVP - Outlook]
> > > Lead Author, Professional Outlook 2000 Programming, Wrox Press
> > > Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
> > > Appendices, Sams



> > > > I create a folder under the Outlook Today - [Personal Folders]
> > > folder using
> > > > the outlook object model, when my addin terminates I want to delete
> > > the
> > > > folder I created.  The problem I have is that the folder gets put
> > > into the
> > > > deleted items folder when I call the method Delete on it.  Is there
> > > any way
> > > > to force it not to put the folder into the deleted items, but just
> > > delete
> > > > it.



Mon, 23 Jun 2003 18:15:51 GMT  
 Delete without going to deleted items folder !
When an item is moved the EntryID property changes, so you can't get
the item using that property. You can trap ItemAdd in the Deleted
Items folder to get the item and use that event to delete from the
Deleted Items folder.

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams



Quote:
> Hi Huw,

> I just asked a very similar question to this! (I am using the object
model
> from C++)

> However I am deleting appointments, whereas you are deleting a
folder.

> I have though of an approach that does not work for me but *might*
work for
> you - I have not tried it though.

> As we know,  if you go into Outlook and delete any appointment or
folder
> from deleted items then it gets properly deleted

> So I figured that I could call Delete on the item twice, once to
*move* it
> to deleted items, and again to delete it properly.

> I maintain a note of the ID of the item, delete it, then attempt to
retrieve
> it again using the ID.

> The key thing is that for Appointments, the attempt to retrieve it
(using
> GetItemFromID) fails.

> However doing the same thing on a folder (but using GetFolderFromID
instead)
> seems to work (in that it retrieves the folder).

> So now you can try calling delete on the folder you just retrieved.

> It might work!

> Tim



Mon, 23 Jun 2003 22:03:12 GMT  
 Delete without going to deleted items folder !
Using EXMAPI if you are developing in C++ or Delphi. In VB or VBA you
would use CDO or trap ItemAdd in the Deleted Items folder and do a
second delete in that event.

You can force the install of CDO, BTW, see Randy Byrne's ItemsCB COM
add-in sample for an example of how to do that. The Office CD's would
have to be available. Randy's COM add-in is at www.microeye.com and a
link is also available in the COM add-in samples at Slipstick at
http://www.slipstick.com/dev/comaddins.htm

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


Quote:
> CDO is not installed on the machine.

> Any other way ?



Mon, 23 Jun 2003 22:07:34 GMT  
 Delete without going to deleted items folder !
Unfortunately, I tried deleting the folder, and then looking for it in the
deleted items folder. I can find it ok, but I get an error message to check
permissions when I call delete on it.



Quote:
> When an item is moved the EntryID property changes, so you can't get
> the item using that property. You can trap ItemAdd in the Deleted
> Items folder to get the item and use that event to delete from the
> Deleted Items folder.

> --
> Ken Slovak
> [MVP - Outlook]
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
> Appendices, Sams



> > Hi Huw,

> > I just asked a very similar question to this! (I am using the object
> model
> > from C++)

> > However I am deleting appointments, whereas you are deleting a
> folder.

> > I have though of an approach that does not work for me but *might*
> work for
> > you - I have not tried it though.

> > As we know,  if you go into Outlook and delete any appointment or
> folder
> > from deleted items then it gets properly deleted

> > So I figured that I could call Delete on the item twice, once to
> *move* it
> > to deleted items, and again to delete it properly.

> > I maintain a note of the ID of the item, delete it, then attempt to
> retrieve
> > it again using the ID.

> > The key thing is that for Appointments, the attempt to retrieve it
> (using
> > GetItemFromID) fails.

> > However doing the same thing on a folder (but using GetFolderFromID
> instead)
> > seems to work (in that it retrieves the folder).

> > So now you can try calling delete on the folder you just retrieved.

> > It might work!

> > Tim



Tue, 24 Jun 2003 01:14:50 GMT  
 Delete without going to deleted items folder !
I'd still recommend using CDO for that. It's the cleanest way.

--
Ken Slovak
[MVP - Outlook]
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Co-author of "Programming Microsoft Outlook 2000", Chapters 8-13,
Appendices, Sams


Quote:
> Unfortunately, I tried deleting the folder, and then looking for it
in the
> deleted items folder. I can find it ok, but I get an error message
to check
> permissions when I call delete on it.



Tue, 24 Jun 2003 05:48:55 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Programmatically delete Deleted Items folder once a day

2. Programmatically delete an item from the Sent Items Folder

3. Detecting an item move to Deleted Items folder

4. Delete without it going to trash bin

5. Deleting mails in deleted folder

6. Smart Delete Files And Smart Delete Folders Routines?

7. Deleting records from a recordset without deleting from the database

8. Checking if a delete will succeed (without doing the delete)

9. Delete deleted items

10. Delete item from a collection class that has no Delete method

11. Q: Recordsets - How to delete items without affecting underlying table

12. VB to Search through Public Folder and Delete Item

 

 
Powered by phpBB® Forum Software