Programmatically delete an item from the Sent Items Folder 
Author Message
 Programmatically delete an item from the Sent Items Folder

I have tried to resolve this myself, but without success.
I also posted this message tem minutes ago, but maybe that
went wrong too ...

Thanks to earlier help from this site I have been able to
get my VB application to send e-mails via Outlook and keep
a copy of the sent e-mail in a Public folder.

Moving on from there, I would also like to be able to
programmatically remove the copy of the e-mail from the
Sent Items folder, leaving just the one in the Public
one.  Is this possible or is there some kind of
restriction in place?

I have tried using the code below, but although it does
not fall over, it does not work either!!

Could someone please review this code and perhaps point me
in the right direction.

I thank you for any help that you can provide.

John J.
---
Note: This code is called directly after the VB
application sends the e-mail.

Sub DeleteSentItem()
    Dim oSentItemsFolder As Outlook.MAPIFolder
    Dim oDeleteFolder As Outlook.MAPIFolder
    Dim objOutlook As Outlook.Application
    Dim oMapi As Outlook.NameSpace
    Dim oItems As Outlook.Items
    Dim oItem As Outlook.MailItem

    Set objOutlook = New Outlook.Application
    Set oMapi = objOutlook.GetNamespace("MAPI")
    Set oSentItemsFolder = oMapi.GetDefaultFolder
(olFolderSentMail)
    Set oDeleteFolder = oMapi.GetDefaultFolder
(olFolderDeletedItems)
    Set oItems = oSentItemsFolder.Items
    Set oItem = oItems.Find("[Subject] = 'Test - Subject'")

    oItem.Delete

    Set objOutlook = Nothing
    Set oMapi = Nothing
    Set oSentItemsFolder = Nothing
    Set oDeleteFolder = Nothing
    Set oItems = Nothing
    Set oItem = Nothing

End Sub



Sun, 24 Jul 2005 23:22:27 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Programmatically delete an item from the Sent items

2. Programmatically delete Deleted Items folder once a day

3. How do I delete an Item in a folder programmatically

4. Detecting an item move to Deleted Items folder

5. Howto trap MAPIFolder.Items.ItemAdd on Sent Items Folder

6. Removal of attachments on email items in Sent items folder

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

8. Deleting MailItems from the Sent Items folder

9. Delete without going to deleted items folder !

10. Delete a Sent Mail from the Sent Item

11. programmatically selecting a tabstrip item without clicking an item

12. Explorer-like interface to Outlook items with mixed type items in a folder

 

 
Powered by phpBB® Forum Software