Solved

Synch Outlook Tasks with an ACCESS Database

Posted on 2008-10-28
9
395 Views
Last Modified: 2013-11-29
I'd like to find a way to synch Outlook 2K3 Tasks with an ACCESS 2K3 database.  I'm in a corporate enviornment, using Exchange 2K7, Outlook 2K3 and ACCESS 2K3 are installed locally.  At the moment I've got to bounce between Outlook Tasks and ACCESS database and what I'd like to do is enter the Task information in Outlook which would synch with my database.

Becuase I'm in a corporate enviornment I can't run any third-party utilities or installation programs.  Nor do I have access to the Exchange server.

Thanks.
Donald.
0
Comment
Question by:birdn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22827255
birdn,

Then simply link the (Outlook) calendar data into Access.

File-->Get External Data-->Link Tables
From the "Files of Type" dropdown, select: Outlook
Expand the "Personal Folders"
Select: Calendar.

JeffCoachman
0
 

Author Comment

by:birdn
ID: 22836522
Great, thanks.

I followed you're directions and get the following Information dialouge box when I select Outlook from the "Files of Type":

There is no object in this control.

I selec OK, and then get a "Link Exchanage/Outlook Wizard" dialouge box with Cancel/Next/Finish as my only options.  Selecting either Next or Finish creates another Information dialouge box and my only option is to select OK.  This takes me back to one screen and my only option is to Cancel.

Thanks.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22837513
Well at least you can see how it is "Supposed to work"!
:-O
LOL.

How is Outlook installed on your machine?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
VeeVan earned 250 total points
ID: 22894786
I can tell you from experience that that doesn't work with regard to tasks. When you "link" them through the system, it puts in a table link, but it is missing the subject field for the task - which does you virtually no good.

Here is some code that will IMPORT the tasks/calendar into Access. You would then add your own code the check for updates, and then write changes back to Outlook. Hopefully, this will get you started though.

NOTE: the Sql statements are inserting to tables that i created in Access. Don't forget to set your reference to the Outlook object library as this example uses early binding.
Option Compare Database
Option Explicit
 
Public Sub Get_OutlookTasks()
On Error GoTo Err_Get_OutlookTasks
 
    'declare and open instance of MS Outlook
    Dim olOutlook As New Outlook.Application
    Dim olNS As Outlook.NameSpace
    Dim olFolders As Outlook.MAPIFolder
    Dim olTasks As Outlook.MAPIFolder
    Dim olItems As Outlook.Items
    Dim olTasksItem As Outlook.TaskItem
    Dim strPST As String, strCriteria As String
    Dim intCounter As Integer
    
    Dim userProp As Object
    
    Dim strSQL As String
    Dim strToday As String
 
        'assign name of outlook PST folder we want to use to string
        'variable
    strPST = "Mailbox - Veronica Van Dyke"
        'set object Outlook NameSpace
    Set olNS = olOutlook.GetNamespace("MAPI")
        'set object NameSpace Folders for PST file
    Set olFolders = olNS.Folders(strPST)
        'set object Tasks folder for PST file
    Set olTasks = olFolders.Folders("Tasks")
        'set object Tasks in folder
    Set olItems = olTasks.Items
 
    DoCmd.SetWarnings False
    
    DoCmd.RunSQL "DELETE * FROM Tasks"
               
        'loop through list of Tasks
    For intCounter = 1 To olItems.Count
        Set olTasksItem = olItems(intCounter)
            If olTasksItem.Complete = False Then
                                
                     If (olTasksItem.UserProperties("Today") Is Nothing) Then
                        Set userProp = olTasksItem.UserProperties.Add("Today", olYesNo, False)
                        strToday = userProp.Value
                     End If
                     
                     Debug.Print strToday
                
                strSQL = "INSERT INTO Tasks ( Duedate, Subject, Category, Today )" & _
                    " SELECT #" & olTasksItem.DueDate & "#, '" & Replace(olTasksItem.Subject, "'", "") & "', '" & olTasksItem.Categories & "', " & strToday & ";"
                    Debug.Print strSQL
                DoCmd.RunSQL strSQL
 
            End If
        
        Debug.Print olTasksItem.Subject
        
    Next intCounter
    
    DoCmd.RunSQL "UPDATE Tasks set DueDate = NULL where DueDate = #1/1/4501#"
    
    MsgBox "Tasks Imported Successfully"
    
Exit_Get_OutlookTasks:
    Set olTasksItem = Nothing
    Set olItems = Nothing
    Set olTasks = Nothing
    Set olFolders = Nothing
    Set olNS = Nothing
    Set olOutlook = Nothing
    Exit Sub
    
Err_Get_OutlookTasks:
    MsgBox Err.Number & ", " & Err.Description, , "Error'"
    Resume Exit_Get_OutlookTasks
        
End Sub
 
 
 
Public Sub Get_OutlookProjects()
On Error GoTo Err_Get_OutlookProjects
 
    'declare and open instance of MS Outlook
    Dim olOutlook As New Outlook.Application
    Dim olNS As Outlook.NameSpace
    Dim olFolders As Outlook.MAPIFolder
    Dim olTasks As Outlook.MAPIFolder
    Dim olItems As Outlook.Items
    Dim olTasksItem As Outlook.TaskItem
    Dim strPST As String, strCriteria As String
    Dim intCounter As Integer
    
    Dim userProp As Object
    
    Dim strSQL As String
    Dim strToday As String
 
        'assign name of outlook PST folder we want to use to string
        'variable
    strPST = "Mailbox - Veronica Van Dyke"
        'set object Outlook NameSpace
    Set olNS = olOutlook.GetNamespace("MAPI")
        'set object NameSpace Folders for PST file
    Set olFolders = olNS.Folders(strPST)
        'set object Tasks folder for PST file
    Set olTasks = olFolders.Folders("Projects")
        'set object Tasks in folder
    Set olItems = olTasks.Items
 
    DoCmd.SetWarnings False
    
    DoCmd.RunSQL "DELETE * FROM Tasks"
               
        'loop through list of Tasks
    For intCounter = 1 To olItems.Count
        Set olTasksItem = olItems(intCounter)
            If olTasksItem.Complete = False Then
                                
                     If (olTasksItem.UserProperties("Today") Is Nothing) Then
                        Set userProp = olTasksItem.UserProperties.Add("Today", olYesNo, False)
                        strToday = userProp.Value
                     End If
                     
                     Debug.Print strToday
                
                strSQL = "INSERT INTO Projects ( Duedate, Subject, Category, Today )" & _
                    " SELECT #" & olTasksItem.DueDate & "#, '" & Replace(olTasksItem.Subject, "'", "") & "', '" & olTasksItem.Categories & "', " & strToday & ";"
                    Debug.Print strSQL
                DoCmd.RunSQL strSQL
 
            End If
        
        Debug.Print olTasksItem.Subject
        
    Next intCounter
    
    DoCmd.RunSQL "UPDATE Projects set DueDate = NULL where DueDate = #1/1/4501#"
    
    MsgBox "Projects Imported Successfully"
    
Exit_Get_OutlookProjects:
    Set olTasksItem = Nothing
    Set olItems = Nothing
    Set olTasks = Nothing
    Set olFolders = Nothing
    Set olNS = Nothing
    Set olOutlook = Nothing
    Exit Sub
    
Err_Get_OutlookProjects:
    MsgBox Err.Number & ", " & Err.Description, , "Error'"
    Resume Exit_Get_OutlookProjects
        
End Sub
 
 
 
Public Sub Get_OutlookCalendar()
On Error GoTo Err_Get_OutlookCalendar
 
    'declare and open instance of MS Outlook
    Dim olOutlook As New Outlook.Application
    Dim olNS As Outlook.NameSpace
    Dim olFolders As Outlook.MAPIFolder
    Dim olCalendar As Outlook.MAPIFolder
    Dim olItems As Outlook.Items
    Dim olCalendarItem As Outlook.AppointmentItem
    Dim strPST As String, strCriteria As String
    Dim intCounter As Integer
    
    Dim userProp As Object
    
    Dim strSQL As String
    Dim strToday As String
 
        'assign name of outlook PST folder we want to use to string
        'variable
    strPST = "Mailbox - Veronica Van Dyke"
        'set object Outlook NameSpace
    Set olNS = olOutlook.GetNamespace("MAPI")
        'set object NameSpace Folders for PST file
    Set olFolders = olNS.Folders(strPST)
        'set object Calendar folder for PST file
    Set olCalendar = olFolders.Folders("Calendar")
        'set object Calendar in folder
    Set olItems = olCalendar.Items
 
    DoCmd.SetWarnings False
    
    DoCmd.RunSQL "DELETE * FROM Calendar"
               
        'loop through list of Calendar
    For intCounter = 1 To olItems.Count
        Set olCalendarItem = olItems(intCounter)
            If olCalendarItem.Start >= Now() And olCalendarItem.Start <= (DateAdd("d", 7, Now())) Then
                                
                strSQL = "INSERT INTO Calendar ( Subject, StartDate, EndDate, Category, Duration )" & _
                    " SELECT '" & Replace(olCalendarItem.Subject, "'", "") & "', #" & olCalendarItem.Start & "#, #" & olCalendarItem.End & "#, '" & olCalendarItem.Categories & "', " & olCalendarItem.Duration & ";"
 
                Debug.Print strSQL
                DoCmd.RunSQL strSQL
 
            End If
        
        Debug.Print olCalendarItem.Subject
        
    Next intCounter
    
    MsgBox "Calendar Imported Successfully"
    
Exit_Get_OutlookCalendar:
    Set olCalendarItem = Nothing
    Set olItems = Nothing
    Set olCalendar = Nothing
    Set olFolders = Nothing
    Set olNS = Nothing
    Set olOutlook = Nothing
    Exit Sub
    
Err_Get_OutlookCalendar:
    MsgBox Err.Number & ", " & Err.Description, , "Error'"
    Resume Exit_Get_OutlookCalendar
        
End Sub

Open in new window

0
 
LVL 1

Expert Comment

by:VeeVan
ID: 22894794
Also, if you do a search on outlook automation, you will get LOTS of code that explains how to add a task/edit a task though VBA.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 22895628
VeeVan,
" it puts in a table link, but it is missing the subject field for the task - which does you virtually no good."

Yeah, I seem to remeber that from a previous question,
I always wondered why this was so.
:-O

JeffCoachman
0
 
LVL 1

Expert Comment

by:VeeVan
ID: 22895664
It is TOTALLY a puzzlement. Microsoft admits that this is the case, says it's by design, and then totally doesn't explain ANY of their reasoning behind it. And to make matters worse, it's true for all of the outlook tables - you can get SOME info.... but nothing even close to making the table links worth your while. I do all my stuff using automation. I threw in the Outlook linked table thing years ago!! Would certainly make life nice if it DID work, though.
0
 
LVL 1

Expert Comment

by:VeeVan
ID: 22895675
I threw in the Outlook = i threw in the towel on this Outlook....
0
 

Author Comment

by:birdn
ID: 22932050
I'll give the code a shot this week and see how it works.  I may need a little more direction.
thx.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question