HOWTO: Open Another User's Schedule Programmatically

Last reviewed: December 18, 1997
Article ID: Q177216
The information in this article applies to:
  • Microsoft Schedule+ for Windows, version 7.0
  • Microsoft Visual Basic Standard and Enterprise Editions for Windows, version 5.0

SUMMARY

There are times when it may be necessary to open the schedule of another user. You may need to look at existing appointments or add new appointments to the schedule. To accomplish this, you need to use the ScheduleForUser Method of the Application object.

MORE INFORMATION

The steps outlined below are required to open the schedule of another user:

  1. Create a Schedule+ object and log in.

  2. Create a MAPI Session object and log in.

  3. Setup a recipient object for the user whose schedule is going to be opened.

  4. Create a valid entry id for the ScheduleForUser call by issuing a resolve.

  5. Open user's schedule using the ScheduleForUser.

  6. Log off of MAPI and Schedule+ and release the objects.

The following code comes from the click event of a Commandbutton called Command1 and demonstrates how to open another user's schedule:

   Private Sub Command1_Click()
      Dim objApp As Object
      Dim objSched As Object
      Dim objOneRecip As Object
      Dim objSession As Object
      Dim objMessage As Object

      'Create a Schedule+ Object

      Set objApp = CreateObject("SchedulePlus.Application")
      objApp.Logon profilename:="cathg (catesp200)"

      'Create a MAPI Session

      Set objSession = CreateObject("MAPI.Session")
      objSession.Logon profilename:="cathg (catesp200)"

      'Setup Recipient Object for the user whose Sschedule you
      'want to open

      Set objMessage = objSession.OutBox.Messages.Add
      Set objOneRecip = objMessage.Recipients.Add
      objOneRecip.Name = "Bugs Bunny"
      objOneRecip.Type = 1

      'Create a valid EntryId for the ScheduleForUser call
      objOneRecip.Resolve

      'Open User's Schedule
      Set objSched = _
            objApp.ScheduleForUser(objOneRecip.AddressEntry.Type _
            + ":" + objOneRecip.AddressEntry.Address, _
            objOneRecip.AddressEntry.Name, 1, 3, _
            objOneRecip.AddressEntry.ID)

      'Print information for user to show you are attached to
      'another schedule
      Debug.Print objSched.UserName
      MsgBox (objSched.UserAddress)

      'Log off of Mail and Schedule+ and release the objects
      objSession.Logoff
      objApp.Logoff

      Set objOneRecip = Nothing
      Set objMessage = Nothing
      Set objSched = Nothing
      Set objSession = Nothing

   End Sub

NOTE: This code only works correctly if the calendar is group enabled. For more information on how to group enable Schedule+, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q141066
   TITLE     : WSPlus: How to Force Schedule+ 7.0 to Ask to Work in Group

Keywords          : kbprg GnrlVB vbwin
Technology        : kbvba
Version           : WINDOWS:5.0,7.0
Platform          : WINDOWS
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.