HOWTO: Open Another User's Schedule Programmatically

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")

      ' Specify a valid profile name for "My Profile"
      objApp.Logon profilename:="My Profile"

      'Create a MAPI Session

      Set objSession = CreateObject("MAPI.Session")
      objSession.Logon profilename:="My Profile"

      'Setup Recipient Object for the user whose schedule 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 


REFERENCES

The code above 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:

Q141066 WSPlus: How to Force Schedule+ 7.0 to Ask to Work in Group

Additional query words:

Keywords : kbprg GnrlVb vbwin
Version : WINDOWS:5.0,7.0
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: October 13, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.