Import Outlook Task Form Data Into Access

D

Donald Fisher

I have several public task folders from which I would like to import the
task information into Access including some form data. I've tried the
table linking deal but it doesn't include the start date and other form
data. I know the EntryIDs and StoreIDs but can't figure out how to make
it import. Any ideas? Here's my current code:


' Set up DAO objects (uses existing "tblTasks" table)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblTasks")


' Set up Outlook objects.
Dim ol As New Outlook.Application
Dim olns As Outlook.NameSpace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.TaskItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty
Dim txtEntryID, txtStoreID

txtEntryID = Screen.ActiveForm.ENTRYID
txtStoreID = Screen.ActiveForm.STOREID

Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetFolderFromID(txtEntryID, txtStoreID)
Set objItems = cf.Items
iNumTasks = objItems.Count
If iNumTasks <> 0 Then
For i = 1 To iNumTasks
If TypeName(objItems(i)) = "TaskItem" Then
Set c = objItems(i)
rst.AddNew
rst!TASK = c.Subject
rst!DueDate = c.DueDate
rst!STARTDATE = c.STARTDATE
rst!Status = c.Status
rst!Rec = c.IsRecurring
rst!SECTION = Screen.ActiveForm.DutySection
rst!Remarks = c.Body
rst.Update
End If
Next i
rst.Close
End If

After the last rst! I would like to add a reference to a field on a
custom tab: (There's the 'TASK' tab and 'MY TAB')

rst!EQUIPID = c.MyCustomTab.EQUIPID (or whatever will work)

Any ideas?
 
B

Brian Tillman

Donald Fisher said:
I have several public task folders from which I would like to import
the task information into Access including some form data. I've tried
the table linking deal but it doesn't include the start date and
other form data. I know the EntryIDs and StoreIDs but can't figure
out how to make it import. Any ideas? Here's my current code:

You might get better answers in the programming newsgroups, like
news://msnews.microsoft.com/microsoft.public.outlook.program_vba
 
M

Mark J. McGinty

Donald Fisher said:
I have several public task folders from which I would like to import the
task information into Access including some form data. I've tried the table
linking deal but it doesn't include the start date and other form data. I
know the EntryIDs and StoreIDs but can't figure out how to make it import.
Any ideas? Here's my current code:


' Set up DAO objects (uses existing "tblTasks" table)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblTasks")


' Set up Outlook objects.
Dim ol As New Outlook.Application
Dim olns As Outlook.NameSpace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.TaskItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty
Dim txtEntryID, txtStoreID

txtEntryID = Screen.ActiveForm.ENTRYID
txtStoreID = Screen.ActiveForm.STOREID

Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetFolderFromID(txtEntryID, txtStoreID)
Set objItems = cf.Items
iNumTasks = objItems.Count
If iNumTasks <> 0 Then
For i = 1 To iNumTasks
If TypeName(objItems(i)) = "TaskItem" Then
Set c = objItems(i)
rst.AddNew
rst!TASK = c.Subject
rst!DueDate = c.DueDate
rst!STARTDATE = c.STARTDATE
rst!Status = c.Status
rst!Rec = c.IsRecurring
rst!SECTION = Screen.ActiveForm.DutySection
rst!Remarks = c.Body
rst.Update
End If
Next i
rst.Close
End If

After the last rst! I would like to add a reference to a field on a custom
tab: (There's the 'TASK' tab and 'MY TAB')

rst!EQUIPID = c.MyCustomTab.EQUIPID (or whatever will work)

Try c.UserProperties("EQUIPID").value (but note that it will throw an
exception if UserProperty doesn't exist.)


-Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top