
Programmatically delete an item from the Sent items
Many thanks for the reply. I have got it to work now, my
problem lay in the finding of the subject, which a later
message between yourself and Ken Slovak regarding 'Using
Apostrophies and quotes in filtering' helped me.
I also had the processing happening too soon after the
item was sent and have adjusted things.
I have got to admit that I was unaware of CDO and have
been reading up on it and that has given me many more
options.
Thank you and the others again for your help on this.
John James
Quote:
>-----Original Message-----
>Your code works perfectly fine for me. Do you want the
deleted message to
>appear in your Deleted Items folder, or have it
permanently deleted? If the
Quote:
>latter, you'll have to use CDO to get a Message object,
which you can
>permanently delete using the Delete(False) method.
Setting it to True puts
Quote:
>it in the Deleted Items folder.
>--
>Eric Legault, MCSD
>ADAPSYS - http://www.adapsys.ca
message
>> Hello all,
>> I've tried and tried, it's not worked and so here I
turn.
>> Thanks to previous help from here, my application is
able
>> to send a e-mail using Outlook and take a copy of that
>> sent item and place it into a public folder. The sent
e-
>> mail remains in the sent items folder as expected.
>> I wish my application to programmatically locate the
sent
>> item and delete it permanently, leaving just the copy in
>> the public folder. Is this actually possible or is the
>> sent items folder restricted in some way?
>> I am getting more familiar with coding with Outlook, but
>> the attached code does not do the job (I thought it
>> might). Please can you review this code and point me in
>> the right direction.
>> I thank you for your help.
>> John J.
>> Note: This routine is called right after the e-mail is
>> sent.
>> 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
Message'")
>> oItem.Delete
>> Set objOutlook = Nothing
>> Set oMapi = Nothing
>> Set oSentItemsFolder = Nothing
>> Set oDeleteFolder = Nothing
>> Set oItems = Nothing
>> Set oItem = Nothing
>> End Sub
>.