Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Use Automation to Add a Task or a Reminder to Microsoft Outlook


View products that this article applies to.

Summary

This article shows you how to use Automation to add a task or a reminder to Microsoft Outlook.

↑ Back to the top


More information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. At times, you may want to programmatically add a task or a reminder to Microsoft Outlook from Access. This article provides sample code that enables you to create a task and play a .wav file as a reminder

NOTE: In the following code, you must point the .ReminderSoundFile property to a valid sound file on your hard disk.

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

  1. Open the sample database Northwind.mdb, and then create a new module.
  2. On the Tools menu, click References.
  3. In the Available References dialog box, click to select the Microsoft Outlook 9.0 Object Library check box, and then click OK.

    NOTE: If the Microsoft Outlook 9.0 Object Library is not listed under Available References, click Browse to locate the Msoutl9.olb file. This file is installed by default in the C:\Program Files\Microsoft Office\Office folder.
  4. Type or paste the following procedure:
    Option Compare Database
    Option Explicit
    
    Function fncAddOutlookTask()
        Dim OutlookApp As Outlook.Application
        Dim OutlookTask As Outlook.TaskItem
    
        Set OutlookApp = CreateObject("Outlook.Application")
        Set OutlookTask = OutlookApp.CreateItem(olTaskItem)
    
        With OutlookTask
            .Subject = "This is the subject of my task"
            .Body = "This is the body of my task."
            .ReminderSet = True
            .ReminderTime = DateAdd("n", 2, Now)    'Remind 2 minutes from now.
            .DueDate = DateAdd("n", 5, Now)         'Due 5 minutes from now.
            .ReminderPlaySound = True
            .ReminderSoundFile = "C:\Windows\Media\Ding.wav"    'Modify path.
            .Save
        End With
    End Function
    					
  5. To test this function, type the following line in the Immediate Window, and then press ENTER:
    ?fncAddOutlookTask()
    					
  6. Start Microsoft Outlook to view the new task.

↑ Back to the top


References

For more information about using Automation to send a Microsoft Outlook e-mail message, please see the following article in the Microsoft Knowledge Base:
209948 ACC2000: How to Use Automation to Send a Microsoft Outlook Message

For information about using automation to add contacts to Microsoft Outlook, please see the following article in the Microsoft Knowledge Base:
209955 ACC2000: How to Use Automation to Create a New Contact Item in Microsoft Outlook
For information about using automation to add appointments to Microsoft Outlook, please see the following article in the Microsoft Knowledge Base:
209963 ACC2000: How to Use Automation to Add Appointments to Microsoft Outlook
For more information about using automation with Microsoft Access, click Microsoft Visual Basic Help on the Help menu, type Understanding Automation in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

↑ Back to the top


Keywords: KB209932, kbfaq, kbhowto

↑ Back to the top

Article Info
Article ID : 209932
Revision : 3
Created on : 6/23/2005
Published on : 6/23/2005
Exists online : False
Views : 371