This article shows you how to use Automation to add a task or a reminder to
Microsoft Outlook.
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:
- Start Microsoft Outlook to view the new task.
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Â
(http://kbalertz.com/Feedback.aspx?kbNumber=209948/EN-US/
)
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Â
(http://kbalertz.com/Feedback.aspx?kbNumber=209955/EN-US/
)
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Â
(http://kbalertz.com/Feedback.aspx?kbNumber=209963/EN-US/
)
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.