Solved

Search for emails by TIME, not date - o2003

Posted on 2006-11-21
7
236 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:DanCh99
  • 3
  • 2
7 Comments
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
Hi, Danny.

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

Cheers!
0
 
LVL 23

Author Comment

by:DanCh99
Comment Utility
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 500 total points
Comment Utility
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:DanCh99
Comment Utility
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
Comment Utility
No problem, Danny.  Take your time.  I'll be here.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
Use email signature images to promote corporate certifications and industry awards.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now