Solved

Synch Outlook Tasks with an ACCESS Database

Posted on 2008-10-28
9
394 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

733 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