Solved

Synch Outlook Tasks with an ACCESS Database

Posted on 2008-10-28
9
386 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Expert Comment

by:VeeVan
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I threw in the Outlook = i threw in the towel on this Outlook....
0
 

Author Comment

by:birdn
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Create high volume marketing opportunities using email signatures with these top 10 DOs and DON'Ts of email signature marketing.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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.

762 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

10 Experts available now in Live!

Get 1:1 Help Now