Finding an outlook appointment using ".find" fuction

G

Guest

I am writing an application to retrieve appointments from Outlook, I have the appointment items sorted by
"Start" field and now I want to find the first record which's "Start" value is later than now (future appointment

The relevant piece of my current code

Dim oCalendar As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar
Dim oItems As Outlook.Items = oCalendar.Item
oItems.Sort("Start"
oItems.IncludeRecurrences = Tru
Dim oAppt As Outlook.AppointmentItem = oItems.Find("[Subject] = ""Flight, CO 0516 2:10pm"""

What is the syntax to replcae the ("[Subject] = ""Flight, CO 0516 2:10pm""") in the last line to reflect what I need
something like ".Find("[Start] >" & Now.ToString)" - which does not wor

Your help is greatly appriciate
Thanks
Ori :)
 
J

Jay B. Harlow [MVP - Outlook]

Ori,
For a list of resources on using Outlook from VB.NET:
http://www.microeye.com/resources/res_outlookvsnet.htm

For help & information on programming Outlook (mostly VB6, some VB.NET):
http://www.outlookcode.com/

Some samples of using Outlook with VB.NET:
http://msdn.microsoft.com/office/de...y/en-us/odc_OL2003_ta/html/odc_OLOMwVBNET.asp

A sample COM Add-in for Outlook written in VB.NET:
http://msdn.microsoft.com/library/d...n-us/odc_OL2003_ta/html/odc_OLWhatsNew2k3.asp


Did you check the online help for specifics on using dates with the Find
method?

It needs to be in the following (VBA) format:

sFilter = "[LastModificationTime] > '" & Format("1/15/99 3:30pm", "ddddd
h:nn AMPM") & "'"

Remember that you can still use the VBA/VB6 Format function in .NET so it
would be:

sFilter = "[LastModificationTime] > '" & Format(Now, "ddddd h:nn AMPM")
& "'"

or if you prefer (unchecked):

sFilter = "[LastModificationTime] > '" & Now.ToString("ddddd h:nn AMPM")
& "'"

Hope this helps
Jay

Ori :) said:
I am writing an application to retrieve appointments from Outlook, I have
the appointment items sorted by
"Start" field and now I want to find the first record which's "Start"
value is later than now (future appointment)
The relevant piece of my current code:

Dim oCalendar As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar)
Dim oItems As Outlook.Items = oCalendar.Items
oItems.Sort("Start")
oItems.IncludeRecurrences = True
Dim oAppt As Outlook.AppointmentItem = oItems.Find("[Subject] = ""Flight, CO 0516 2:10pm""")

What is the syntax to replcae the ("[Subject] = ""Flight, CO 0516
2:10pm""") in the last line to reflect what I need ?
something like ".Find("[Start] >" & Now.ToString)" - which does not work

Your help is greatly appriciated
Thanks !
Ori :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top