Quantcast
VBA - Count Emails older Than - Beyond.ca - Car Forums
Results 1 to 2 of 2

Thread: VBA - Count Emails older Than

  1. #1
    Join Date
    Aug 2011
    Location
    Strathmore
    My Ride
    2005 Dirtymax
    Posts
    2,222
    Rep Power
    22

    Default VBA - Count Emails older Than

    I am trying to create a spreadsheet in Excel that when you run a button it will scan your mailbox for emails older than a specific time and produce a count of how many there are.

    I already have a script that will run and count how many total are in the mailbox and how many in the mail box are not read. But I'd like to have this also calculate the above.

    Any VBA + Outlook experts?

    Code:
    Sub countMail()
    
    Dim objoutlook As Object, objnSpace As Object, objFolder As Object
    Dim EmailCount As Integer
    
    Set objoutlook = CreateObject("Outlook.Application")
    Set objnSpace = objoutlook.GetNamespace("MAPI")
    
        On Error Resume Next
        Set objFolder = objnSpace.Folders("mailbox").Folders("Inbox")
        If Err.Number <> 0 Then
        Err.Clear
        MsgBox "No such folder."
        Exit Sub
        End If
    
    unreadCount = objFolder.UnReadItemCount
    rcvdEmailCount = objFolder.Items.Count
    
    shiftDayStartAMER = Date
    shiftTimeStartAMER = " 7:45:00 AM"
    shiftAMER = shiftDayStartAMER & shiftTimeStartAMER
    
    ThisWorkbook.Sheets("Sheet1").Activate
    Cells(2, 2).Value = rcvdEmailCount
    Cells(4, 2).Value = unreadCount
    
    End Sub
    Last edited by firebane; 01-14-2019 at 01:20 PM.

  2. #2
    Join Date
    May 2004
    Location
    Calgary
    My Ride
    Ford, Acura
    Posts
    2,227
    Rep Power
    56

    Default

    The guys at https://www.excelforum.com/ have been extremely helpful to me for this sort of thing. Maybe give them a shot?
    Quote Originally Posted by rage2 View Post
    This quote is hidden because you are ignoring this member. Show Quote
    ...Last thing I want is someone reading my posts and losing their cock over it...
    Quote Originally Posted by Sugarphreak
    This quote is hidden because you are ignoring this member. Show Quote
    Meh, they all look like Jackie Chan to me
    Quote Originally Posted by ExtraSlow View Post
    This quote is hidden because you are ignoring this member. Show Quote
    I'm generally cute.

Similar Threads

  1. LF: Someone who can program an Excel VBA macro

    By CanadianFC in forum Careers
    Replies: 1
    Latest Threads: 04-12-2013, 07:51 AM
  2. VBA coding help!

    By urbannomad in forum Careers
    Replies: 7
    Latest Threads: 05-11-2011, 10:55 AM
  3. Excel VBA Help

    By Boat in forum Computer Help Desk
    Replies: 0
    Latest Threads: 10-23-2010, 05:12 PM
  4. VBA Coding Question

    By Si_FlyGuy in forum Computers, Consoles, and other Electronics
    Replies: 3
    Latest Threads: 08-08-2006, 09:39 AM
  5. Older than BBJ, but I laffed

    By Xtrema in forum General
    Replies: 11
    Latest Threads: 10-01-2005, 07:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •