Delete deleted items 
Author Message
 Delete deleted items

Hi!

I would like to know why this bit of code doesn't work. I want, in an vb.net
outllook addin, to delete contacts in deleted items with an "Acomba"
category. Works for Contact folder but not for Deleted Items: (Thanks a
lot!)

Dim objDeletedFolder As Outlook.MAPIFolder
Dim objsDeleted As Outlook.Items
Dim objDeleted As Object

' Specify which contact folder to work with
objDeletedFolder =
app.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedItems)
objsDeleted = objDeletedFolder.Items

For Each objDeleted In objsDeleted
If TypeName(objDeleted) = "ContactItem" Then
If objDeleted.Categories = "Acomba" Then
objDeleted.Delete()
End If
End If
Next

' Clean up
objDeleted = Nothing
objsDeleted = Nothing
objDeletedFolder = Nothing



Mon, 14 Nov 2005 02:58:02 GMT  
 Delete deleted items
For one thing, always use a down counting For loop when you are
deleting items from a collection. Otherwise you will only delete 1/2
the items at best in each pass through the loop.

Are you getting a valid MAPIFolder and Items collection?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Quote:
> Hi!

> I would like to know why this bit of code doesn't work. I want, in
an vb.net
> outllook addin, to delete contacts in deleted items with an "Acomba"
> category. Works for Contact folder but not for Deleted Items:
(Thanks a
> lot!)

> Dim objDeletedFolder As Outlook.MAPIFolder
> Dim objsDeleted As Outlook.Items
> Dim objDeleted As Object

> ' Specify which contact folder to work with
> objDeletedFolder =

app.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedI
tems)

- Show quoted text -

Quote:
> objsDeleted = objDeletedFolder.Items

> For Each objDeleted In objsDeleted
> If TypeName(objDeleted) = "ContactItem" Then
> If objDeleted.Categories = "Acomba" Then
> objDeleted.Delete()
> End If
> End If
> Next

> ' Clean up
> objDeleted = Nothing
> objsDeleted = Nothing
> objDeletedFolder = Nothing



Mon, 14 Nov 2005 20:49:43 GMT  
 Delete deleted items
Thanks for the tip. To answer your question, what do i have to do to know if
my MAPIFolder and items collection are valid? app is the current Outllook
application object. My code works for the default Contact folder. Is it
possible that the received deleted folder is not the good one?

Thanks,

Asimov.



Quote:
> For one thing, always use a down counting For loop when you are
> deleting items from a collection. Otherwise you will only delete 1/2
> the items at best in each pass through the loop.

> Are you getting a valid MAPIFolder and Items collection?

> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Lead Author, Beginning VB 6 Application Development, Wrox Press
> Attachment Options
> http://www.slovaktech.com/attachmentoptions.htm
> Extended Reminders
> http://www.slovaktech.com/extendedreminders.htm



> > Hi!

> > I would like to know why this bit of code doesn't work. I want, in
> an vb.net
> > outllook addin, to delete contacts in deleted items with an "Acomba"
> > category. Works for Contact folder but not for Deleted Items:
> (Thanks a
> > lot!)

> > Dim objDeletedFolder As Outlook.MAPIFolder
> > Dim objsDeleted As Outlook.Items
> > Dim objDeleted As Object

> > ' Specify which contact folder to work with
> > objDeletedFolder =

> app.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedI
> tems)
> > objsDeleted = objDeletedFolder.Items

> > For Each objDeleted In objsDeleted
> > If TypeName(objDeleted) = "ContactItem" Then
> > If objDeleted.Categories = "Acomba" Then
> > objDeleted.Delete()
> > End If
> > End If
> > Next

> > ' Clean up
> > objDeleted = Nothing
> > objsDeleted = Nothing
> > objDeletedFolder = Nothing



Mon, 14 Nov 2005 23:49:28 GMT  
 Delete deleted items
Info: The goal of my code is to delete contacts with the category "Acomba".
The job is well in the contact folder but all contacts are transfered in the
deleted items. Is there a way to shift-del contacts in contact folder?

Thanks.



Quote:
> For one thing, always use a down counting For loop when you are
> deleting items from a collection. Otherwise you will only delete 1/2
> the items at best in each pass through the loop.

> Are you getting a valid MAPIFolder and Items collection?

> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Lead Author, Beginning VB 6 Application Development, Wrox Press
> Attachment Options
> http://www.slovaktech.com/attachmentoptions.htm
> Extended Reminders
> http://www.slovaktech.com/extendedreminders.htm



> > Hi!

> > I would like to know why this bit of code doesn't work. I want, in
> an vb.net
> > outllook addin, to delete contacts in deleted items with an "Acomba"
> > category. Works for Contact folder but not for Deleted Items:
> (Thanks a
> > lot!)

> > Dim objDeletedFolder As Outlook.MAPIFolder
> > Dim objsDeleted As Outlook.Items
> > Dim objDeleted As Object

> > ' Specify which contact folder to work with
> > objDeletedFolder =

> app.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDeletedI
> tems)
> > objsDeleted = objDeletedFolder.Items

> > For Each objDeleted In objsDeleted
> > If TypeName(objDeleted) = "ContactItem" Then
> > If objDeleted.Categories = "Acomba" Then
> > objDeleted.Delete()
> > End If
> > End If
> > Next

> > ' Clean up
> > objDeleted = Nothing
> > objsDeleted = Nothing
> > objDeletedFolder = Nothing



Tue, 15 Nov 2005 02:37:59 GMT  
 Delete deleted items
To check for a valid MAPIFolder and Items you would see if they are
Nothing after you try to instantiate them.

You can only "hard" delete items using CDO 1.21 or Extended MAPI.

For more information about using DotNet code with Outlook see
http://www.microeye.com/resources/res_outlookvsnet.htm

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Quote:
> Info: The goal of my code is to delete contacts with the category
"Acomba".
> The job is well in the contact folder but all contacts are
transfered in the
> deleted items. Is there a way to shift-del contacts in contact
folder?

> Thanks.



Tue, 15 Nov 2005 20:44:46 GMT  
 Delete deleted items
The delete method found ine CDO seems the same than the one i used. And
Extended MAPI seems to need Exchange to be used.

Am i on the good track? Do you have a code exemple of hard delete?

Thanks.



Quote:
> To check for a valid MAPIFolder and Items you would see if they are
> Nothing after you try to instantiate them.

> You can only "hard" delete items using CDO 1.21 or Extended MAPI.

> For more information about using DotNet code with Outlook see
> http://www.microeye.com/resources/res_outlookvsnet.htm

> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Lead Author, Beginning VB 6 Application Development, Wrox Press
> Attachment Options
> http://www.slovaktech.com/attachmentoptions.htm
> Extended Reminders
> http://www.slovaktech.com/extendedreminders.htm



> > Info: The goal of my code is to delete contacts with the category
> "Acomba".
> > The job is well in the contact folder but all contacts are
> transfered in the
> > deleted items. Is there a way to shift-del contacts in contact
> folder?

> > Thanks.



Tue, 15 Nov 2005 22:42:16 GMT  
 Delete deleted items
PMJI, but I have a code sample at http://www.outlookcode.com/codedetail.aspx?id=41 that demonstrates how to use CDO 1.21 to permanently delete an item.

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
     Microsoft Outlook Programming: Jumpstart
     for Administrators, Power Users, and Developers
     http://www.slipstick.com/books/jumpstart.htm

Quote:

> The delete method found ine CDO seems the same than the one i used. And
> Extended MAPI seems to need Exchange to be used.

> Am i on the good track? Do you have a code exemple of hard delete?

> Thanks.



> > To check for a valid MAPIFolder and Items you would see if they are
> > Nothing after you try to instantiate them.

> > You can only "hard" delete items using CDO 1.21 or Extended MAPI.

> > For more information about using DotNet code with Outlook see
> > http://www.microeye.com/resources/res_outlookvsnet.htm

> > --
> > Ken Slovak
> > [MVP - Outlook]
> > http://www.slovaktech.com
> > Lead Author, Professional Outlook 2000 Programming, Wrox Press
> > Lead Author, Beginning VB 6 Application Development, Wrox Press
> > Attachment Options
> > http://www.slovaktech.com/attachmentoptions.htm
> > Extended Reminders
> > http://www.slovaktech.com/extendedreminders.htm



> > > Info: The goal of my code is to delete contacts with the category
> > "Acomba".
> > > The job is well in the contact folder but all contacts are
> > transfered in the
> > > deleted items. Is there a way to shift-del contacts in contact
> > folder?

> > > Thanks.



Wed, 16 Nov 2005 00:17:23 GMT  
 Delete deleted items
Thanks a lot!!!! Just a last question: What assembly do i have to import to
use CDO Objects?

Also, i visited your site. Usefull one! If i create a distribution list with
CDO, does the outlook security warning will appear?

Asimov.



PMJI, but I have a code sample at
http://www.outlookcode.com/codedetail.aspx?id=41 that demonstrates how to
use CDO 1.21 to permanently delete an item.

--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
     Microsoft Outlook Programming: Jumpstart
     for Administrators, Power Users, and Developers
     http://www.slipstick.com/books/jumpstart.htm


Quote:
> The delete method found ine CDO seems the same than the one i used. And
> Extended MAPI seems to need Exchange to be used.

> Am i on the good track? Do you have a code exemple of hard delete?

> Thanks.



> > To check for a valid MAPIFolder and Items you would see if they are
> > Nothing after you try to instantiate them.

> > You can only "hard" delete items using CDO 1.21 or Extended MAPI.

> > For more information about using DotNet code with Outlook see
> > http://www.microeye.com/resources/res_outlookvsnet.htm

> > --
> > Ken Slovak
> > [MVP - Outlook]
> > http://www.slovaktech.com
> > Lead Author, Professional Outlook 2000 Programming, Wrox Press
> > Lead Author, Beginning VB 6 Application Development, Wrox Press
> > Attachment Options
> > http://www.slovaktech.com/attachmentoptions.htm
> > Extended Reminders
> > http://www.slovaktech.com/extendedreminders.htm



> > > Info: The goal of my code is to delete contacts with the category
> > "Acomba".
> > > The job is well in the contact folder but all contacts are
> > transfered in the
> > > deleted items. Is there a way to shift-del contacts in contact
> > folder?

> > > Thanks.



Wed, 16 Nov 2005 02:12:50 GMT  
 Delete deleted items
Exchange is not required for Extended MAPI but it can only be used
with C++ or Delphi.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Quote:
> The delete method found ine CDO seems the same than the one i used.
And
> Extended MAPI seems to need Exchange to be used.

> Am i on the good track? Do you have a code exemple of hard delete?

> Thanks.



Wed, 16 Nov 2005 02:39:00 GMT  
 Delete deleted items
You didn't mention that you were using .Net. CDO 1.21 is a COM component, but is not supported in .Net, at least not for accessing Exchange data.

I would expect creating a DL with CDO to trigger security prompts, but I've never actually tried it.

Quote:

> Thanks a lot!!!! Just a last question: What assembly do i have to import to
> use CDO Objects?

> Also, i visited your site. Usefull one! If i create a distribution list with
> CDO, does the outlook security warning will appear?

> Asimov.



> PMJI, but I have a code sample at
> http://www.outlookcode.com/codedetail.aspx?id=41 that demonstrates how to
> use CDO 1.21 to permanently delete an item.

> --
> Sue Mosher, Outlook MVP
> Outlook and Exchange solutions at http://www.slipstick.com
> Author of
>      Microsoft Outlook Programming: Jumpstart
>      for Administrators, Power Users, and Developers
>      http://www.slipstick.com/books/jumpstart.htm



> > The delete method found ine CDO seems the same than the one i used. And
> > Extended MAPI seems to need Exchange to be used.

> > Am i on the good track? Do you have a code exemple of hard delete?

> > Thanks.



> > > To check for a valid MAPIFolder and Items you would see if they are
> > > Nothing after you try to instantiate them.

> > > You can only "hard" delete items using CDO 1.21 or Extended MAPI.

> > > For more information about using DotNet code with Outlook see
> > > http://www.microeye.com/resources/res_outlookvsnet.htm

> > > --
> > > Ken Slovak
> > > [MVP - Outlook]
> > > http://www.slovaktech.com
> > > Lead Author, Professional Outlook 2000 Programming, Wrox Press
> > > Lead Author, Beginning VB 6 Application Development, Wrox Press
> > > Attachment Options
> > > http://www.slovaktech.com/attachmentoptions.htm
> > > Extended Reminders
> > > http://www.slovaktech.com/extendedreminders.htm



> > > > Info: The goal of my code is to delete contacts with the category
> > > "Acomba".
> > > > The job is well in the contact folder but all contacts are
> > > transfered in the
> > > > deleted items. Is there a way to shift-del contacts in contact
> > > folder?

> > > > Thanks.



Wed, 16 Nov 2005 03:57:23 GMT  
 Delete deleted items
Ok. Let's recap.

Need:
-to permanently delete an item
-my project is in VB.NET using PIA assembly
-the addin has to be exchange-free

Problem:
-the contact in the contact folder is deleted but a copy is created in
deleted items
-i can't suppress items in deleted items

Constraints:
-i cannot use Extended MAPI because it can only be used with C++ or Delphi
-i cannot use CDO because the projet is in .NET
-my addin is redistribuable, then i cannot use Redemption

Is there a solution to my problem?
Is it possible to permanently delete an item with PIA assembly?
Is it possible to use CDO 1.21 with Visual Studio .NET to permanently delete
an item? If yes, do you have an example to use CDO in vs.net?

Thanks,

Asimov.



Quote:
> Exchange is not required for Extended MAPI but it can only be used
> with C++ or Delphi.

> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Lead Author, Professional Outlook 2000 Programming, Wrox Press
> Lead Author, Beginning VB 6 Application Development, Wrox Press
> Attachment Options
> http://www.slovaktech.com/attachmentoptions.htm
> Extended Reminders
> http://www.slovaktech.com/extendedreminders.htm



> > The delete method found ine CDO seems the same than the one i used.
> And
> > Extended MAPI seems to need Exchange to be used.

> > Am i on the good track? Do you have a code exemple of hard delete?

> > Thanks.



Wed, 16 Nov 2005 04:49:27 GMT  
 Delete deleted items
You can uniquely mark the item (e.g. by setting the Mileage property to a
unique value), delete the item, then find the deleted item in the "Deleted
Items" folder (use MAPIFolder.Items.FindFirst) and delete it again.

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


Quote:
> Ok. Let's recap.

> Need:
> -to permanently delete an item
> -my project is in VB.NET using PIA assembly
> -the addin has to be exchange-free

> Problem:
> -the contact in the contact folder is deleted but a copy is created in
> deleted items
> -i can't suppress items in deleted items

> Constraints:
> -i cannot use Extended MAPI because it can only be used with C++ or Delphi
> -i cannot use CDO because the projet is in .NET
> -my addin is redistribuable, then i cannot use Redemption

> Is there a solution to my problem?
> Is it possible to permanently delete an item with PIA assembly?
> Is it possible to use CDO 1.21 with Visual Studio .NET to permanently
delete
> an item? If yes, do you have an example to use CDO in vs.net?

> Thanks,

> Asimov.



> > Exchange is not required for Extended MAPI but it can only be used
> > with C++ or Delphi.

> > --
> > Ken Slovak
> > [MVP - Outlook]
> > http://www.slovaktech.com
> > Lead Author, Professional Outlook 2000 Programming, Wrox Press
> > Lead Author, Beginning VB 6 Application Development, Wrox Press
> > Attachment Options
> > http://www.slovaktech.com/attachmentoptions.htm
> > Extended Reminders
> > http://www.slovaktech.com/extendedreminders.htm



> > > The delete method found ine CDO seems the same than the one i used.
> > And
> > > Extended MAPI seems to need Exchange to be used.

> > > Am i on the good track? Do you have a code exemple of hard delete?

> > > Thanks.



Sat, 19 Nov 2005 01:33:57 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Programmatically delete Deleted Items folder once a day

2. Delete without going to deleted items folder !

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

4. SQL delete query deletes but does not delete

5. Programmatically delete an item from the Sent items

6. Programmatically delete an item from the Sent Items Folder

7. How to delete selective items from Sent Items from PF Script

8. Detecting an item move to Deleted Items folder

9. deleting an item or item set from a database

10. rst.delete, with cascade delete???

11. Deleting mails in deleted folder

12. Deleting page doesn't delete command buttons

 

 
Powered by phpBB® Forum Software