none
Looping appointments in calendar RRS feed

  • Question

  • Hello experts,

    In a scenery where folders represents meeting rooms and people reserve this meetings rooms creating appointments in the calendars of this folders.

    Is there a way to know if exists any free meeting room right now ?

    I´m looping all the folders and his appointments manipulating .start property, mas there are many of them and the code is slow.

    Also exists the problem of recurrency appointments that not start today, but in the past.

    Thanks
    Thursday, June 11, 2015 4:34 PM

Answers

All replies

  • Hello Andre,

    Looping through items in multiple folders is not a good idea from the performance perspective. Instead, I'd suggest using the AdvancedSearch method of the Application class which performs a search based on a specified DAV Searching and Locating (DASL) search string. Take a look at the following pages for more information and sample code:

    Advanced search in Outlook programmatically: C#, VB.NET

    How to use the AdvancedSearch method to search for an item in Outlook

    In case if you need to search items in the single folder use the Find/FindNext or Restrict methods of the Items class.


    Thursday, June 11, 2015 5:24 PM
  • Pass the name of the room to Application.Session.CreateRecipient, call Recipient.Resolve, then use Recipient.FreeBusy method to retrieve a string representing the room availability for the given time range.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, June 11, 2015 8:21 PM
  • Eugene,

    thanks for help

    I´m trying to build the filter

    Dmitry,

    Thanks, but is not working.

    Returns error -2147467259 in the FreeBusy line.

    What I´m doing wrong ?

    Dim olns As NameSpace

    Dim myRecipient As Outlook.recipient

    Set olns = GetNamespace("MAPI") Set accs = olns.Accounts Set objFolder = Outlook.Application.Session.GetDefaultFolder(18) Set pastaVM = objFolder.Folders("VM") Set calendariosCompany = pastaVM.Folders("Calendários das Salas de Reuniões Company") For Each pasta In calendariosCompany.Folders Set myRecipient = olns.CreateRecipient("10º Andar - Sala Colômbia - 12 Pessoas - Vídeo Conferência | Ramal:4904") myRecipient.Resolve MsgBox myRecipient.FreeBusy(#6/15/2015#, 10)


    Monday, June 15, 2015 12:59 PM
  • The error is the generic MAPI_E_CALL_FAILED.

    Do you see FB for that particular recipient in Outlook?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, June 15, 2015 2:10 PM
  • At the moment of the test this recipient was BUSY.

    I try again with another free recipient and obtain the same error.

    Just to remember, i´m not working with MEETING ROOMS, but with the calendar of some folders.

    Monday, June 15, 2015 2:35 PM
  • What is "calendar of some folders"? When you schedule an appointment, you add the attendee on the Attendees tab and you can see the f/b just fine, right?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, June 15, 2015 9:58 PM
  • Hi André,

    Base on my test with outlook 2013, if I use the meeting room’s name, it throws the exception, if I use the meeting room’s address, it works fine. (works fine for user’s name and address)

    Please try to use meeting room’s address and check the result.

    Regards                      

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, June 16, 2015 2:23 AM
    Moderator
  • Dmitry,

    Let me try to explain,

    There is an object named MEETING ROOM in outlook.This object is the right way to represents places to have a meeting.


    At my job, we don´t use this resource, we don´t have meeting rooms registered.

    Then how we reserve a place ?

    The rooms are represented by public folders, and when a person needs to use that place, he creates an appointment in the calendar of that folder, that have the name of a meeting room.

    Understood ??

    Thank you so much by your help.. I´m a newbie with oulook.

    Tuesday, June 16, 2015 11:46 AM
  • If you are creating an appointment directly in a PF store folder, you really have no choice but to access the items in that folder explicitly. You can use Items.IncludeRecurrences / Start / Find. See sample code at https://msdn.microsoft.com/en-us/library/office/aa171434%28v=office.11%29.aspx?f=255&MSPPError=-2147217396 

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by André Santo Tuesday, June 16, 2015 7:31 PM
    Tuesday, June 16, 2015 3:20 PM
  • It works...

    Certainly, that´s the best way

    fhanks

    Tuesday, June 16, 2015 7:32 PM
  • Andre,

    I suggested that way initially. There is no need to invent a wheel.

    Tuesday, June 16, 2015 8:11 PM
  • Really,

    What´s wrong is the way how we use the resource here in company.

    The performance is not good, i don´t know if i go release the tool
    Tuesday, June 16, 2015 9:02 PM
  • Which OOM call is the bottleneck? How long does it take?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, June 16, 2015 10:52 PM
  • The .FIND method.

    It takes 1 second per meeting room (folder).

    There are 21 folders

    Nowadays, anybody waits a operation that takes all this time.

    I´m thinking in show just the first free meeting room, instead list all.



    If I leave the VBA and develop this as an C# APP, I will get a better performance ?

    Wednesday, June 17, 2015 11:08 AM
  • Try to use the AdvancedSearch method of the Application class instead. First, you can search in multiple folders. Second, the search is run in the background. 

    In case of add-ins - the Outlook object model can't be used on secondary threads (unless it was run there). The only possible option is to use Extended MAPI which allows to call properties and methods from another threads. 

    Wednesday, June 17, 2015 11:20 AM
  • Eugene,

    Could you help me here ?

    Dim sch As Outlook.Search
    Dim rsts As Outlook.Results
    
        tdystart = VBA.Format(Now, "Short Date")
        tdyend = VBA.Format(Now + 1, "Short Date")
    
    nomePasta = pasta.Name
    
    strF = "[Start] >= """ & tdystart & """ and [Start] <= """ & tdyend & """"
    
    Set sch = Application.AdvancedSearch(nomePasta, strF, True)

    err.number = -2147023281 

    nomePasta = "10º Andar - Sala Colômbia - 12 Pessoas - Vídeo Conferência | Ramal:4904"

    strF = [Start] >= "17/06/2015" and [Start] <= "18/06/2015"


    Wednesday, June 17, 2015 12:24 PM
  • You may find the query builder helpful. See Chapter 11: Searching Outlook Data .
    Wednesday, June 17, 2015 1:14 PM
  • 1 second per folder (which is most likely not cached) does not sound all that unreasonable.

    If you were using C++ or Delphi, you could switch to Extended MAPI which can be used from a secondary thread. If using Redemption is an option, its RDO family of objects can be used on a secondary thread. It has an extra benefit of exposing the RDOFolder2.GetActivitiesForTimeRange method, which returns a collection of appointment in the specified time range (expanding recurring appointments if necessary).


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, June 17, 2015 2:16 PM