![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hi,
I have a smal program that add contacts from a database to a Contact Folder i Outlook I start with deleting all contacts that have a certian attribute and everything else works fine.. The bad thing is that the deleted items show up in the trashcan whish fill up quite fast that way so the code below works but not quite as good as I want. Does any one know how to delete items without having them go inte the trashcan? Sub Deletetems() Dim myOlApp As Outlook.Application Dim myNamespace As Outlook.NameSpace Dim myFolder As Outlook.MAPIFolder Dim myItems As Outlook.Items Dim myRestrictItems As Outlook.Items Dim myItem As Outlook.MailItem Set myOlApp = CreateObject("Outlook.Application") Set myNamespace = myOlApp.GetNamespace("MAPI") Set myFolder = myNamespace.GetDefaultFolder(olFolderContacts) Set myItems = myFolder.Items Set myRestrictItems = myItems.Restrict("[ReferredBy] ''") For i = myRestrictItems.Count To 1 Step -1 myRestrictItems(i).Delete Next End Sub /Fredrik |
Ads |
#2
|
|||
|
|||
![]()
When you delete using the Outlook object model the deleted items always go
to the Deleted Items folder. No way around that. If you use CDO 1.21 or Redemption or Extended MAPI code you can delete an item without it's being added to Deleted Items. You could monitor the ItemAdd event on the Items collection of the Deleted Items folder. If a new item is added that's a contact (you can add a user property to the ones you delete for id purposes) then delete it from Deleted Items. It's a hack but it works and only uses Outlook object model code. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Fredrik Nelson" wrote in message ... Hi, I have a smal program that add contacts from a database to a Contact Folder i Outlook I start with deleting all contacts that have a certian attribute and everything else works fine.. The bad thing is that the deleted items show up in the trashcan whish fill up quite fast that way so the code below works but not quite as good as I want. Does any one know how to delete items without having them go inte the trashcan? Sub Deletetems() Dim myOlApp As Outlook.Application Dim myNamespace As Outlook.NameSpace Dim myFolder As Outlook.MAPIFolder Dim myItems As Outlook.Items Dim myRestrictItems As Outlook.Items Dim myItem As Outlook.MailItem Set myOlApp = CreateObject("Outlook.Application") Set myNamespace = myOlApp.GetNamespace("MAPI") Set myFolder = myNamespace.GetDefaultFolder(olFolderContacts) Set myItems = myFolder.Items Set myRestrictItems = myItems.Restrict("[ReferredBy] ''") For i = myRestrictItems.Count To 1 Step -1 myRestrictItems(i).Delete Next End Sub /Fredrik |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Add ContactItems to DLItem with VBS | Christoph Fricke | Outlook and VBA | 8 | May 10th 06 06:03 PM |
How to Really Delete Sent items? | [email protected] | Outlook - General Queries | 5 | May 2nd 06 06:59 AM |
how to delete an account | T5 | Outlook Express | 4 | March 29th 06 07:54 PM |
can not delete | ALROL | Outlook Express | 1 | February 27th 06 03:36 PM |
Delete is permanent?? | Angyl | Outlook - Using Forms | 6 | February 8th 06 10:35 PM |