Solved

Search for emails by TIME, not date - o2003

Posted on 2006-11-21
7
272 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 500 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

SuperAntiSpyware Licenses Discounted by 25% !

Exclusive offer to Experts Exchange Members!
Buy SuperAntiSpyware License(s) from us and save 25% on the regular purchase price.
- Includes Full SuperAntiSpyware Vendor Support Entitlements
- Your Subscription does not begin until you activate your license
- Buy for your friends

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
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 …
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…

732 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