![]() |
|
||||||||
| Site Links |
| Consulting |
| Knowledge Base |
| Training |
| Forum |
| Articles |
| Resources |
| Products |
| Cool Tools |
| Contact |
| About Us |
| Go to Page... |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
|
Extract / Count Outlook Public Folder Emails based on Date Range in Excel
Hello All
I have put together some code in excel from various sources online(VBA X and others) to extract outlook emails from a series of public folders, its working fine but I would like to amend the code to only extract email based on a date range. At the moment its taking ages to run as its extracting all emails everytime I run it, I only need to run a weeks worth each time. I will update the week commencing date(start date) on a summary sheet in excel and would like the macro to extract only emails in the folder based on that week(7days). I'm not sure if I can do that using the method currently used. Any help with this matter would be greatly appreciated! Current working code below that is used for 1 of the folder counts. Regards Carrotkiller VBA:
VBA tags courtesy of www.thecodenet.com
|
|
Local Time: 06:05 AM
Local Date: 05-22-2013 Location:
|
|
|
|
#2 |
|
|
Use the Items.Restrict Method to filter the collection by date. Here are some examples:
http://msdn.microsoft.com/en-us/library/bb220369(v=office.12).aspx Regards, JP Read the FAQ Getting free help on the web My website Please use [vba][/vba] tags when posting code |
|
Local Time: 06:05 AM
Local Date: 05-22-2013 Location:
|
|
|
|
#3 |
|
|
Thanks for the reply Jp, I'll see if I can get that working tomorrow.
Cheers |
|
Local Time: 06:05 AM
Local Date: 05-22-2013 Location:
|
|
|
|
#4 |
|
|
Hi JP
My Outlook VBA knowledge is limited, could not get it working,tried another way-but still seems to be extracting all emails in the folder!! Any ideas on how to amend the below to get it working? Many Thanks VBA:
VBA tags courtesy of www.thecodenet.com
|
|
Local Time: 06:05 AM
Local Date: 05-22-2013 Location:
|
|
|
|
#5 |
|
|
You must apply the filter to the Items collection you want to iterate. Since objfolder points to the folder, create a new object that points to that folder's Items collection, i.e.
Now you have an Items collection on which to use the Restrict method (based on the link I posted earlier). What I would do is use a second Items object to hold the filtered collection, like this: VBA:
VBA tags courtesy of www.thecodenet.com
Now you can check itms.Count, loop through the filtered collection and write each email's properties to Excel. Regards, JP Read the FAQ Getting free help on the web My website Please use [vba][/vba] tags when posting code |
|
Local Time: 06:05 AM
Local Date: 05-22-2013 Location:
|
|
|
|
#6 |
|
|
Hi JP
Thanks for taking the time to reply and supplying the code snippits, I managed to get it working with your help Final code below for anyone interested: VBA:
VBA tags courtesy of www.thecodenet.com
Thanks Again Regards Carrotkiller |
|
Local Time: 06:05 AM
Local Date: 05-22-2013 Location:
|
|
|
|
#7 |
|
|
Congrats and +1 to you for your effort!
Regards, JP Read the FAQ Getting free help on the web My website Please use [vba][/vba] tags when posting code |
|
Local Time: 06:05 AM
Local Date: 05-22-2013 Location:
|
|
![]() |
| Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|


