Deleting a message from your inbox after replying.

D

Dave

I would like to find a way to add a macro or button to outlook so that when I
reply to a message, I have the option of deleting the original message from
my inbox upon sending the reply. Something like a 'Send and Delete Original
Message' button. The idea is inspired by the Inbox Zero idea of deleting mail
as soon as it's been dealt with.

I found this example that demonstrates how to delete the item from the sent
mail folder upon sending:
http://www.vboffice.net/sample.html?mnu=2&pub=6&lang=en&smp=38&cmd=showitem

However, it looks like it works by changing the properties of the currently
opened message. I don't know how to adapt it to my needs though. Is it
possible to get a reference to the originating message from a new reply?
 
K

Ken Slovak - [MVP - Outlook]

You can get the original of a reply by using the ConversationTopic and
ConversationIndex properties. Assuming the originals are all in your Inbox
you can set up a restriction on the ConversationTopic property in the
Inbox's Items collection to only return those items with the same
ConversationTopic as your reply item.

The ConversationIndex property is created on each new thread or
conversation, consisting of a date/time structure stamp. Then each
subsequent member of that conversation adds a new date/time stamp to the
property. That would allow you to verify that an item is the parent of the
reply by checking the lengths of the property.

So if this type code was running in the reply item it would return the
original:

' oReply is the reply item
Dim sTopic As String
sTopic = oReply.ConversationTopic
Dim colItems As Outlook.Items
Dim colMyTopic As Outlook.Items
Dim myOriginal As Outlook.MailItem

' Application is Outlook.Application in Outlook VBA project
Set colIems = Application.Session.GetDefaultFolder(olFolderInbox).Items
Set colMyTopic = colItems.Restrict("[ConversationTopic] = '" & sTopic & "'")
If colMyTopic.Count = 1 Then
'we found it no need for more tests
Set myOriginal = colMyTopic.Item(1)
Else
' we need to iterate the filtered collection and check each item's
ConversationIndex length,
' then compare it to any other items in the filtered collection and to
the reply item.
' The item with the length just one date stamp shorter than the reply is
our original
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top