?
Solved

Search for emails by TIME, not date - o2003

Posted on 2006-11-21
7
Medium Priority
?
282 Views
Last Modified: 2010-04-08
Hi,
can I search a mailbox for emails within a certain time window?  For instance - between 17:00 and 23:59?

I've tried the standard search ..Advanced Tab.. Date and Time.. Sent.. Between.. 17:00 and 23:59
and similar permutations, but they either return nothing, or everything...

A filter would also work ok, but I get the same problem - I guess the search and filter use similar formats.

Needed to identify work done out of hours - searching Inbox and Sent Items primarily, or everything....

thanks,
Danny
0
Comment
Question by:Danny Child
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 17988824
Hi, Danny.

I can do this with a bit of scripting if that's an option.

Cheers!
0
 
LVL 23

Author Comment

by:Danny Child
ID: 18001963
That would work, but if it's a chore, then don't bother.  This isn't a showstopper issue.  Happy to bump the points tho! (like you need them....!)

I saw the SQL query options in the Find dialog, is that any cleverer/easier?  But as I know burger all about SQL queries, I can't suss it myself.
ta for the reply tho.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 18008916
DanCh99,

No, it's not too much of a chore.  It's an interesting problem.  Here's one possible solution.  Follow these instructions to use it.

1.  Start Outlook.
2.  Click Tools->Macro->Visual Basic Editor.
3.  If not already expanded, expand Modules and click on Module1.
4.  Copy the code below and paste it into the right-hand pane of the VB Editor.
5.  Edit the code as needed.  I placed comment lines where things need to change.
6.  Click the diskette icon on the toolbar to save the changes.
7.  Close the VB Editor.
8.  Click Tools->Macro->Security.
9.  Change the Security Level setting to Medium.
10.  Select a folder that contains mail items and run the macro.
11.  The macro outputs its results to an HTML file and then opens that file in IE when it's finished.  The messages subjects are linked back to the mail item in Outlook.


Sub FindAllMessagesInAGivenTimeframe()
    Dim datStartTime As Date, _
        datEndTime As Date, _
        datMsgTime As Date, _
        strFilename As String, _
        olkFolder As Outlook.Items, _
        olkMessage As Outlook.MailItem, _
        objFSO As Object, _
        objResults As Object
    'Change the file name and path of the output file on teh next line
    strFilename = "C:\eeTesting\Search Results.htm"
    'Change the time range to look for on the following two lines
    datStartTime = #8:00:00 AM#
    datEndTime = #12:00:00 PM#
    Set olkFolder = Application.ActiveExplorer.CurrentFolder.Items
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objResults = objFSO.CreateTextFile(strFilename)
    objResults.WriteLine "<div align=""center""><b>Search Results</b><br>"
    objResults.WriteLine "Searching folder: " & olkFolder.Parent.FolderPath & "</div>"
    objResults.WriteLine "<p><table><tr><td width=""80%""><b>Subject</b></td><td width=""20%""><b>Received</b></td></tr>"
    For Each olkMessage In olkFolder
        datMsgTime = CDate(Hour(olkMessage.ReceivedTime) & ":" & Minute(olkMessage.ReceivedTime) & ":" & Second(olkMessage.ReceivedTime))
        If (datMsgTime >= datStartTime) And (datMsgTime <= datEndTime) Then
            objResults.WriteLine "<tr><td><a href=""Outlook:" & olkMessage.EntryID & """>" & olkMessage.Subject & "</a></td><td>" & olkMessage.ReceivedTime & "</td></tr>"
        End If
    Next
    objResults.WriteLine "</table></p>"
    objResults.Close
    Set objResults = Nothing
    Set objFSO = Nothing
    Set olkMessage = Nothing
    Set olkFolder = Nothing
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Navigate2 "file://" & strFilename
    Do While objIE.readyState <> 4
        DoEvents
    Loop
    objIE.Visible = True
    Set objIE = Nothing
End Sub
0
 
LVL 23

Author Comment

by:Danny Child
ID: 18019452
looks good.  I'm having a bit of a mental day here, will get to test it soon.  
please bear with me...
Danny
0
 
LVL 76

Expert Comment

by:David Lee
ID: 18024014
No problem, Danny.  Take your time.  I'll be here.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question