Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can VBA report on email sent times?

Status
Not open for further replies.

BatFace

Technical User
Oct 17, 2001
24
AU
Hi Everyone,

I don't see outlook with vba info here often, but I'm hoping someone might be able to point me in the general direction...I've never used VBA with outlook before, so at the moment I'm not even sure this is possible.


I need to generate a report from outlook (2000) that shows what time an email was received, then what time it was replied to. I work for a company that has a set email turnaround time, however, we receive too many emails to manually check the turnaround time, and not enough emails to spend $$$ on a package to do this for us....Can anyone think of a VBA solution, or something I might be able to do?


Thanks again for your help, I appreciate it!

[bat]
 
Hi BatFace

If you set up an Outlook object in VBA there's a property called ReceivedTime which returns Date/Time that an email was received, and CreationTime = when an item was created. We're not using Outlook here so I can't test the code, but Perhaps this'll help:

Code:
Sub CheckMailTime()
    ' Define variables for MS Outlook objects
    Dim oAppOutl As Outlook.Application
    Dim oNameSpace As Outlook.NameSpace
    Dim oInbox As Outlook.MAPIFolder
    Dim oMailItem As Outlook.MailItem
    
    ' Set Outlook object (NB - Outlook must be open or code'll fail)
    Set oAppOutl = GetObject("", "Outlook.Application")
    ' Set MAPI name space
    Set oNameSpace = oAppOutl.GetNamespace("MAPI")
    ' Set Inbox object
    Set oInbox = oNameSpace.GetDefaultFolder(olFolderInbox)
    
    'Loop thru' inbox & check date/time recvd for each mailitem
    For Each oMailItem In oInbox.Items
        MsgBox oMailItem.Subject & " received on: " & oMailItem.ReceivedTime
        MsgBox oMailItem.Subject & " created on: " & oMailItem.CreationTime
    Next oMailItem
    
    'Clean  up objects
    Set oAppOutl = Nothing
    Set oNameSpace = Nothing
    Set oInbox = Nothing
    
End Sub

Cheers
Nikki

 
Also look into the mailitem_reply event - you may be able to use this to keep track of the reply time.
Rob
[flowerface]
 
Thanks so much everyone - it's working really well!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top