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



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q209932
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

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

SUMMARY

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

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.

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.

Modification Type:MajorLast Reviewed:6/23/2005
Keywords:kbhowto KB209932