ACC: Using Automation to Add a Task/Reminder to MS Outlook

Last reviewed: February 27, 1998
Article ID: Q162371
The information in this article applies to:
  • Microsoft Access versions 7.0, 97

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

This article demonstrates how to add a task or a reminder to Microsoft Outlook using Automation with Visual Basic for Applications.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.

There may be times when you would like to programatically add a task or a reminder to Outlook from Microsoft Access. This article provides sample code that enables you to create a task and play a .wav file as a reminder.

NOTE: You must point the .ReminderSoundFile property to a valid sound file on your hard drive.

MORE INFORMATION

To add a task or a reminder to Microsoft Outlook, follow these steps:

  1. Start Microsoft Access and open the sample database Northwind.mdb.

  2. Create a module and type the following line in the Declarations section if it is not already there:

          Option Explicit
    

  3. On the Tools menu, click References.

  4. Click Microsoft Outlook 8.0 Object Library in the Available References box.

    NOTE: If this object library is not available in the References list, click Browse to locate the Msoutl8.olb file, which is installed by default in the C:\Program Files\Microsoft Office\Office folder.

  5. Type the following procedure:

          Function AddOutLookTask()
    
             Dim appOutLook As Outlook.Application
             Dim taskOutLook As Outlook.TaskItem
             Set appOutLook = CreateObject("Outlook.Application")
             Set taskOutLook = appOutLook.CreateItem(olTaskItem)
          With taskOutLook
              .Subject = "This is the subject of my task"
              .Body = "This is the body of my task."
              .ReminderSet = True
              .ReminderTime = DateAdd("n", 2, Now)  ' Set to remind us 2
                                                    ' minutes from now.
              .DueDate = DateAdd("n", 5, Now)       ' Set the due date to
                                                    ' 5 minutes from now.
              .ReminderPlaySound = True
               'add the path to a .wav file on your computer.
              .ReminderSoundFile = "C:\Win95\media\ding.wav"
              .Save
          End With
         End Function
    
    

  6. To test this function, type the following line in the Debug window, and then press ENTER.

           ?AddOutLookTask()
    

    Note that a new task is added to Microsoft Outlook.

REFERENCES

For information about using Automation to add appointments to Microsoft Outlook, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q160502
   TITLE     : ACC: Using Automation to Add Appointments to Microsoft
               Outlook

For more information about using Automation with Microsoft Access, search the Help Index for "Automation," or ask the Microsoft Access 97 Office Assistant.


Additional query words: OutSol OutSol97 OutSol98

Keywords : kbole IntpOleA kbfaq
Technology : kbole
Version : 7.0 97
Platform : WINDOWS
Hardware : x86
Issue type : kbinfo


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: February 27, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.