![]() |
|
|
#1 |
|
Administrator
VP-Knowledge Base |
Solved: Delete older emails with same subject line
As I receive quite a few emails with the same subject line from VBA Express, is there a macro I can run which will delete all the older messages with duplicate subject lines, leaving only the newest?
MD PS I have never attempted Outlook macros. ![]() |
|
Local Time: 10:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#2 |
|
Knowledge Base Approver
|
Hi Malcom
I had a crack at this below, the code moves the older messages into a subfolder called "Old". I'm wary whether the code always moves the correct old message with this line olInbox.Items(olItem.Subject).Move olDupe In my testing it worked but..... The code uses a Dictionary Object to hold the subject name and sender (so it wont cull messages from different senders with the same subject). I've used early binding so you need to set a reference to Microsoft Scripting Runtime. I think that the Find method would be a superior way of doing this speedwise, I'll have a play Cheers Dave VBA:
VBA tags courtesy of www.thecodenet.com
|
|
Local Time: 07:38 PM
Local Date: 07-30-2010 Location:
|
|
|
|
#3 |
|
Administrator
VP-Knowledge Base |
Thanks Dave,
It works a treat on Inbox, but I commonly have one level of sub-folder within inbox so I've tweaked your code to the following: VBA:
VBA tags courtesy of www.thecodenet.com
|
|
Local Time: 10:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#4 |
|
Knowledge Base Approver
|
Malcolm,
Did it always move the older message? I'm not sure if the code needs a sort routine or not. Please note this change as the inbox may contain meeting requests, voicemail etc Cheers Dave |
|
Local Time: 07:38 PM
Local Date: 07-30-2010 Location:
|
|
|
|
#5 |
|
Administrator
VP-Knowledge Base |
Hi Dave,
It works fine. With the change I made, I only have emails in the two designated folders, but a useful filter anyway. Thanks Malcolm |
|
Local Time: 10:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#6 |
|
|
This is the second time I've tried posting here.
I guess I pushed the wrong button the first time. VBA:
VBA tags courtesy of www.thecodenet.com
|
|
Local Time: 04:38 AM
Local Date: 07-30-2010 |
|
|
|
#7 |
|
Administrator
VP-Knowledge Base |
Hi Howard,
I saw your earlier posting, now superceded by this one. I think you should reinstate your comments as to what this revised coding does. MD MVP (Excel) "Provide sample data and layout if you want a quicker solution." - MD To help indent your macros try Smart Indent A Collection of Useful Articles by XL-Dennis |
|
Local Time: 10:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#8 |
|
|
Hi MD
Using the above cause Outlook to prompt a security msg stating that a program is trying to gain access to the address book, is there a way to do away this security msg. Thanks Our Greatest Glory is not in never falling, but in rising every time we fall ![]() There is great satisfaction in building good tools for others to use
|
|
Local Time: 01:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#9 |
|
Administrator
VP-Knowledge Base |
I don't believe so
http://www.vbaexpress.com/forum/showthread.php?t=7847 MVP (Excel) "Provide sample data and layout if you want a quicker solution." - MD To help indent your macros try Smart Indent A Collection of Useful Articles by XL-Dennis |
|
Local Time: 10:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#10 | |||||||||||||||||||||||
|
|
I have a look at the link provided, and removing New Outlook works in Thanks ![]() Our Greatest Glory is not in never falling, but in rising every time we fall ![]() There is great satisfaction in building good tools for others to use
|
|||||||||||||||||||||||
|
Local Time: 01:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#11 |
|
|
Hi MD,
Error msg ' Variables not defined ' appear for this line when I run your marco for a another layer of sub folder. Would appreciate your guide on this line Thanks Our Greatest Glory is not in never falling, but in rising every time we fall ![]() There is great satisfaction in building good tools for others to use
|
|
Local Time: 01:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#12 |
|
Administrator
VP-Knowledge Base |
See what happens when I don't use Option Explicit!
Should be I had two sub-folders within "Inbox", EE & VBA. MVP (Excel) "Provide sample data and layout if you want a quicker solution." - MD To help indent your macros try Smart Indent A Collection of Useful Articles by XL-Dennis |
|
Local Time: 10:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#13 |
|
|
MD, Excellent!!
Thanks Our Greatest Glory is not in never falling, but in rising every time we fall ![]() There is great satisfaction in building good tools for others to use
|
|
Local Time: 01:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#14 |
|
|
Hi, I got compile error on line
Dim olDict As Dictionary Error is 'User-defined type not defined'. I have outlook 2000, any thoughts. |
|
Local Time: 05:38 AM
Local Date: 07-30-2010 |
|
|
|
#15 |
|
Administrator
VP-Knowledge Base |
Hi Skasu,
Welcome to VBAX Did you notice this line? Regards MD MVP (Excel) "Provide sample data and layout if you want a quicker solution." - MD To help indent your macros try Smart Indent A Collection of Useful Articles by XL-Dennis |
|
Local Time: 10:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#16 | |||||||||||||||||||||||||||||||||||||||||
|
|
I have tried to search Outlooks own help and I'll go on Google after I've posted this, but...obvious Noobie here...what is "Microsoft Scripting Runtime", how do you create a reference to it and what is the effect?
|
|||||||||||||||||||||||||||||||||||||||||
|
Local Time: 09:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#17 | |||||||||||||||||||||||||||||||||||||||||
|
|
Own question answered, GIMF... http://msdn.microsoft.com/en-us/library/aa164509(office.10).aspx
|
|||||||||||||||||||||||||||||||||||||||||
|
Local Time: 09:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#18 | ||||||||||||||||||
|
|
Ok, this code works but in my case, I'm not looking to remove older emails in *my* inbox. I'm looking to remove older emails in a group mailbox which I can see like this...
[quote] Mailbox - Thegaul, Asterix
|
||||||||||||||||||
|
Local Time: 09:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#19 | ||||||||||||||||||
|
|
Code works fine but in my case I'm looking to remove older emails from a shared groupbox, displayed like this...
- Mailbox - Thegaul, Asterix Archive Deleted Items Drafts Inbox Junk E-mail Outbox Sent Items Search Folders - Mailbox - Groupbox, Our Deleted Items Inbox Outbox Sent Items Search Folders It's the "- Mailbox - Groupbox, Our", "Inbox" that I want to remove the older emails from. Any idea how I can modify this code to do this?
|
||||||||||||||||||
|
Local Time: 09:38 AM
Local Date: 07-30-2010 Location:
|
|
|
|
#20 |
|
Administrator
VP-Knowledge Base |
Hi Asterix,
Post your question in the Outlook forum for a quicker result MVP (Excel) "Provide sample data and layout if you want a quicker solution." - MD To help indent your macros try Smart Indent A Collection of Useful Articles by XL-Dennis |
|
Local Time: 10:38 AM
Local Date: 07-30-2010 Location:
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|