R
Rob
Hi all,
I am not sure if this is the right group, but I have an issue when
automating tasks between Access and Outlook.
The issue relate to the warning box that Outlook displays. I have the
following code to add and retreive tasks:
Public Function AddTaskToOutlook(strSubject As String, dtDueDate As Date,
Optional strBody As String, Optional dtReminder As Date)
Dim appOutlook As Outlook.Application
Dim appTask As Outlook.TaskItem
Dim i As Integer
Set appOutlook = New Outlook.Application
Set appTask = appOutlook.CreateItem(olTaskItem)
With appTask
.Subject = strSubject
.DueDate = dtDueDate
If strBody <> vbNullString Then
.Body = strBody
End If
If dtReminder Then
.ReminderTime = dtReminder
.ReminderSet = True
.ReminderPlaySound = True
End If
.Save
End With
Set appTask = Nothing
Set appOutlook = Nothing
End Function
and
Public Function GetOutlookTaskData(strID As String) As Variant
Dim appOutlook As Outlook.Application
Dim appNameSpace
Dim appTasksFolder
Dim appTasks As Outlook.Items
Dim appTask As Outlook.TaskItem
Dim i As Integer
Dim varRtn As Variant
Dim strSubject As String
Set appOutlook = New Outlook.Application
Set appNameSpace = appOutlook.GetNamespace("MAPI")
Set appTasksFolder = appNameSpace.GetDefaultFolder(olFolderTasks)
Set appTasks = appTasksFolder.Items
For i = 1 To appTasks.Count
Set appTask = appTasks(i)
strSubject = appTask.Subject
If InStr(strSubject, strID) <> 0 Then
'varRtn = adhPutItem(varRtn, "Body", appTask.Body)
varRtn = adhPutItem(varRtn, "DueDate", appTask.DueDate)
varRtn = adhPutItem(varRtn, "Subject", strSubject)
End If
Set appTask = Nothing
Next
GetOutlookTaskData = varRtn
Set appTasks = Nothing
Set appTasksFolder = Nothing
Set appNameSpace = Nothing
Set appOutlook = Nothing
End Function
The AddTaskToOutlook function works as expected, and I do not receive any
warning boxes. When I run the GetOutlookTaskData function Outlook displays
the warning box and asks for access only when I try and access the Body
property of the TaskItem. I was wondering why there is a difference between
the two functions.
Cheers
Rob
I am not sure if this is the right group, but I have an issue when
automating tasks between Access and Outlook.
The issue relate to the warning box that Outlook displays. I have the
following code to add and retreive tasks:
Public Function AddTaskToOutlook(strSubject As String, dtDueDate As Date,
Optional strBody As String, Optional dtReminder As Date)
Dim appOutlook As Outlook.Application
Dim appTask As Outlook.TaskItem
Dim i As Integer
Set appOutlook = New Outlook.Application
Set appTask = appOutlook.CreateItem(olTaskItem)
With appTask
.Subject = strSubject
.DueDate = dtDueDate
If strBody <> vbNullString Then
.Body = strBody
End If
If dtReminder Then
.ReminderTime = dtReminder
.ReminderSet = True
.ReminderPlaySound = True
End If
.Save
End With
Set appTask = Nothing
Set appOutlook = Nothing
End Function
and
Public Function GetOutlookTaskData(strID As String) As Variant
Dim appOutlook As Outlook.Application
Dim appNameSpace
Dim appTasksFolder
Dim appTasks As Outlook.Items
Dim appTask As Outlook.TaskItem
Dim i As Integer
Dim varRtn As Variant
Dim strSubject As String
Set appOutlook = New Outlook.Application
Set appNameSpace = appOutlook.GetNamespace("MAPI")
Set appTasksFolder = appNameSpace.GetDefaultFolder(olFolderTasks)
Set appTasks = appTasksFolder.Items
For i = 1 To appTasks.Count
Set appTask = appTasks(i)
strSubject = appTask.Subject
If InStr(strSubject, strID) <> 0 Then
'varRtn = adhPutItem(varRtn, "Body", appTask.Body)
varRtn = adhPutItem(varRtn, "DueDate", appTask.DueDate)
varRtn = adhPutItem(varRtn, "Subject", strSubject)
End If
Set appTask = Nothing
Next
GetOutlookTaskData = varRtn
Set appTasks = Nothing
Set appTasksFolder = Nothing
Set appNameSpace = Nothing
Set appOutlook = Nothing
End Function
The AddTaskToOutlook function works as expected, and I do not receive any
warning boxes. When I run the GetOutlookTaskData function Outlook displays
the warning box and asks for access only when I try and access the Body
property of the TaskItem. I was wondering why there is a difference between
the two functions.
Cheers
Rob