F
Fredrik Nelson
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
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