Microsoft KB Archive/209932

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

Article ID: 209932

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



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:

 Open the sample database Northwind.mdb, and then create a new module. On the Tools menu, click References. 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.  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   To test this function, type the following line in the Immediate Window, and then press ENTER: ?fncAddOutlookTask  Start Microsoft Outlook to view the new task.</li></ol>

<div class="references_section">