![]() |
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
|
|||
|
|||
![]()
Can anyone tell me how to write a rule that will delete previous e-mails with
the same number in the subject? I receive e-mails with subjects similar to the following: "XYZ Company Issue #5506384." I would like Outlook to only keep the most recent version of the e-mail for that issue. The e-mails are sent by various employees from the company and the subject may have additional words after the issue number. Any help would be greatly appreciated! |
Ads |
#2
|
|||
|
|||
![]()
No rule alone could do that. You would need to define a rule that called a
procedure in your VBA project and use that procedure to do what you wanted. The procedure would look something like this: Sub KillOlderConversationItems(MyMail As Outlook.MailItem) Dim sConversationTopic As String Dim sConversationIndex As String Dim oFolder As Outlook.MAPIFolder Dim colItems As Outlook Items Dim colMyItems As Outlook.Items Dim oNS As Outlook.NameSpace Dim lCount As Long Dim i As Long Dim oMail As Outlook.MailItem sConversationTopic = MyMail.ConversationTopic sConversationIndex = MyMail.ConversationIndex Set oNS = Application.GetNameSpace("MAPI") Set oFolder = oNS.GetDefaultFolder(olFolderInbox) Set colItems = oFolder.Items Set colMyItems = colItems.Restrict("[ConversationTopic] = " & _ Chr(34) & sConversationTopic & Chr(34) lCount = colMyItems.Count For i = lCount To 1 Step -1 Set oMail = colMyItems.Item(i) If Len(oMail.ConversationIndex) Len(MyMail.ConversationIndex) Then oMail.Delete End If Next Set oMail = Nothing Set oNS = Nothing Set colMyItems = Nothing Set colItems = Nothing Set oFolder = Nothing End Sub That "script" would be called from your rule. This sub as shown doesn't do any error handling or checking to see if every item is a MailItem. It also will filter on items that have identical ConversationTopic property values, which should do what you want as long as all the items are part of a conversation thread. If you want items that aren't associated that just have the same number in the Subject you'd have to loop over the entire collection in the folder and check for Subject containing that number for each item. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "amsmith" wrote in message ... Can anyone tell me how to write a rule that will delete previous e-mails with the same number in the subject? I receive e-mails with subjects similar to the following: "XYZ Company Issue #5506384." I would like Outlook to only keep the most recent version of the e-mail for that issue. The e-mails are sent by various employees from the company and the subject may have additional words after the issue number. Any help would be greatly appreciated! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Delete tasks from mail subject | vbadude_sl | Outlook and VBA | 4 | March 1st 07 03:46 PM |
no subject e mails, how do I deal with them? | T5 | Outlook - General Queries | 8 | November 25th 06 06:45 PM |
Delete future recurring appointments, retain previous. | Blick TX | Outlook - Calandaring | 1 | June 16th 06 04:20 PM |
New message To, CC, BCC and Subject fields don't accept 'delete' | [email protected] | Outlook - General Queries | 3 | May 25th 06 08:34 PM |
Date: and Subject: Can I delete/hide them? | Richelle | Outlook - General Queries | 4 | February 7th 06 03:57 PM |