#1
|
|||
|
|||
Retrict Method Condition
Hello, I'm trying to write a vba function to retrieve a task that I place in the task folder through vba.
Here is the code to place the task. This code is in an Access 2002 db program. Code:
Function fncAddOutlookTask(TaskSubject As String, TaskBody As String, TaskDueDate As Date, _ TaskReminder As Boolean) Dim OutlookApp As Outlook.Application Dim OutlookTask As Outlook.TaskItem Set OutlookApp = CreateObject("Outlook.Application") Set OutlookTask = OutlookApp.CreateItem(olTaskItem) With OutlookTask .Subject = TaskSubject .Body = TaskBody .DueDate = TaskDueDate .ReminderSet = TaskReminder .ReminderPlaySound = True .ReminderSoundFile = "C:\Windows\Media\Ding.wav" 'Modify path. .Save End With End Function Code:
Function fncRetrieveOutlookTask(TaskSubject As String) Dim OutlookApp As Outlook.Application Dim MyTaskList As Outlook.Items Dim MyTask As TaskItem Set OutlookApp = CreateObject("Outlook.Application") Set MyTaskList = OutlookApp.GetNamespace("MAPI").GetDefaultFolder(olFolderTasks). _ Items.Restrict("[Subject] Like '" & TaskSubject & "*'") If MyTaskList.Count = 1 Then Set MyTask = MyTaskList.Item(0) Debug.Print MyTask.Subject & " - " & MyTask.CreationTime Else For Each MyTask In MyTaskList Debug.Print MyTask.Subject & " - " & MyTask.CreationTime Next End If End Function Any ideas? Thanks Mark |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Shared Contacts & Calendars. Best method | crobertson | Outlook | 1 | 05-08-2009 05:47 AM |
Method to update saves to all copies | aultduell | Word | 1 | 11-24-2006 12:50 PM |
filesaveas method for ms project in c# results in error | mikimik | Project | 0 | 10-12-2006 07:53 AM |