VBOffice

How Many Appointments Do You Have Today?

The sample gets you the number of appointments or meetings of a given day.

Last modified: 2006/01/20 | Accessed: 72.378  | #13
◀ Previous sample Next sample ▶
SAM SAM
Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.

The sample gets the number of appointments of a given day - also including recurrings. The returned value tells you that number. Via the optional argument oResult you get access to the found items.


tip  How to add macros to Outlook
Public Function AppointmentsAtDay(ByVal dtDate As Date, _
  Optional oResult As Outlook.Items _
) As Long
  Dim oFld As Outlook.MAPIFolder
  Dim oItems As Outlook.Items
  Dim sFind As String
  Dim obj As Object
  Dim i As Long

  Set oFld = Application.Session.GetDefaultFolder(olFolderCalendar)
  Set oItems = oFld.Items

  oItems.Sort "[Start]", False
  oItems.IncludeRecurrences = True

  sFind = Format(dtDate, "ddddd")

  sFind = "[Start] <= " & _
            Chr(34) & sFind & " 11:59 PM" & Chr(34) & _
            " AND [End] > " & _
            Chr(34) & sFind & " 12:00 AM" & Chr(34)

  Set oResult = oItems.Restrict(sFind)
  For Each obj In oResult
    i = i + 1
  Next
  AppointmentsAtDay = i
End Function
Category-Manager Category-Manager
With Category-Manager you can group your Outlook categories, share them with other users, filter a folder by category, automatically categorize new emails, and more. You can use the Addin even for IMAP.
email  Send a message