Solved

Search for emails by TIME, not date - o2003

Posted on 2006-11-21
7
247 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
  • 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Yahoo's http mail server URL 4 15,770
transfer from exchange mails to gmail 10 95
Exchange 2003 converted to VM but now email does not work 5 60
Exchange 2010 searching 3 39
Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

929 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

13 Experts available now in Live!

Get 1:1 Help Now