Solved

Synch Outlook Tasks with an ACCESS Database

Posted on 2008-10-28
9
388 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
  • 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
 
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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now