Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Mar 2005
    Canberra, Australian Capital Territory, Australia
    Thanked 0 Times in 0 Posts

    Outlook via Access (2003)

    I'm just a little confused about the various terms when querying Outlook from Access.


    Dim olApp As New Outlook.Application
    Dim nmSp As NameSpace
    Dim mpFld As MAPIFolder
    Dim objItm As Object

    Set nmSp = olApp.GetNamespace("MAPI")
    Set mpFld = nmSp.GetDefaultFolder(olFolderCalendar)
    Set objItm = mpFld.Items.Find("[Subject]=""Some sort of Meeting""")

    I think that the following mean, as code examples:

    objItm.Subject ' means the subject body of the meeting
    objItm.Start ' means the date of the meeting
    objItm.Duration 'means the duration of the meeting
    objItm.Body ' means the body of the meeting text

    Is this correct?

    If it is, then I presume that to find all meetings on a particular date (objItm.Start) then one has to do something like:

    set objItm = mpFld.Items.Find("[Start]=""#03/10/2003#""") ' to find meetings today but this doesn't feel right!!

    I want to start doing the normal .BOF and .EOF but haven't the first idea of what to do!

    I'm lost, and need help where to go from here (that's if here is a valid starting point anyway!)

    Thank you


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Outlook via Access (2003)

    The following example is from the online help for Outlook 2002 VBA. It finds all items that start today.
    Set myOlApp = CreateObject("Outlook.Application")
    Set myNameSpace = myOlApp.GetNameSpace("MAPI")
    tdystart = Format(Date, "Short Date") & " 12:00 AM"
    tdyend = Format(Date, "Short Date") & " 11:59 PM"
    Set myAppointments = myNameSpace.GetDefaultFolder _
    Set currentAppointment = myAppointments.Find("<!t>[Start]<!/t> >= """ & _
    tdystart & """ and <!t>[Start]<!/t> <= """ & tdyend & """")
    Do While TypeName(currentAppointment) <> "Nothing"
    MsgBox currentAppointment.Subject
    Set currentAppointment = myAppointments.FindNext
    The code shows how to handle dates in a Find instruction (you can replace Date with a specific date), and how to loop through the found items.

Posting Permissions

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