Results 1 to 2 of 2
Thread: Outlook via Access (2003)
2005-03-10, 10:26 #1
- 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!)
2005-03-10, 11:02 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 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"
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.