cancel
Showing results for 
Search instead for 
Did you mean: 

outlook olFolderCalender find subject

Former Member
0 Kudos

Hi all

I will find a subject in the outlook calender. The connect to outlook works but I need help for this:

  • search a subject e.g. 'My Meeting in city'
  • start search from a certain date e.g. 06/29/2015

Who can help me for this.

This is my working code without search

Hope this code is ok!

l_result = ole_outlook.ConnectToNewObject("outlook.application")

ole_namespace = ole_outlook.GetNameSpace("MAPI")

ole_folder = ole_namespace.GetDefaultFolder( olFolderCalendar )

s_name = ole_folder.Name

l_return = ole_folder.items.Count

?     dt_Start = ole_folder.Items(o).Start

?     ole_folder.start = string( dti_start_datum, 'dd.mm.yyyy' )

for o = 1 to l_return

?     l_result = ole_folder.Find("[Subject] = 'My Meeting in city'")

//  s_subject = trim(String(ole_folder.Items(o).Subject))

//  d_date = date(ole_folder.Items(o).start)

//  d_start = datetime(ole_folder.Items(o).start)

//  d_end = datetime(ole_folder.Items(o).end)

next

ole_outlook.DisconnectObject()

destroy ole_outlook

return

André Rust

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos
Former Member
0 Kudos

Hi all

when I add an appointment in Outlook, then is there an ID that I can fall back later?

I will save this ID for delete the appointment in the future.

How can I find the appointment with this ID?

How can I delete the appointment  with this ID?

André Rust

Former Member
0 Kudos

You can use Namespace.GetItemFromID method to find the item.

To delete an appointment you can try the delete method of AppointmentItem object.

Former Member
0 Kudos

Hi René,


I have implemented it with the namespace. Delete the works now.

Only with the date range (Code VBA) I do not understand quite.

You might have yet another example of this (perhaps even in the PB Code). I want from a specific date browse the appointments.

Thanks

André Rust

Former Member
0 Kudos

Hi André,

sorry, I have no powerbuilder example. But it is not difficult to change the VBA code to a powerbuilder code. The example uses the retrict method to find all items in a specific date range. If you only need to specify the start date you can change the filter string.

For more information about the date format see here: Using the Find and Restrict methods to search for dates

Then a different filter is used on the result to filter by subject.

Instead of For-Each-Loop you have to use a FOR-TO-NEXT-Loop from 1 to oFinalItems.Count as in your code.

I have never tried it out, but hope it helps you.

René

Former Member
0 Kudos

Hi René

The problem is that I can do that not with the [Start].

I have done this:

s_start = "[Start] >= '" + string( dti_start_date, 'dd.mm.yyyy hh:mm' )

but as I sat down this value for Outlook?

in ole_namespace

ole_namespace = ole_outlook.GetNameSpace( "MAPI" )

or ole_folder

ole_folder = ole_namespace.GetDefaultFolder( olFolderCalendar )

ole_folder.start = s_start

ole_namespace.start = s_start

ole_folder.item.start= s_start

ole_folder.items.start= s_start


all are crash


André Rust

Former Member
0 Kudos

Look at the example! There are no start properties in that objects.

- Build a find string like s_start (There is a missing ' at the end of the find string!) Maybe you have to use another date format (see the link in my previous posting)

- Use the Restrict method of Items object: ole_range = ole_folder.items.restrict(s_start)

- ole_range conains now a list of the items that match the find

- build a find string for filter by subject

- Use ole_result = ole_range.Retrict(...) to filter

- Loop through result: FOR i = 1 TO ole_result.Count