This section shows how you can export information stored in an Outlook Journal folder
into a Microsoft Access table. This can be useful if you are using the Journal folder in
Outlook to keep a history of a project. You can store this information in Microsoft Access
where you can sort and view it in several ways.
The following code sample assumes that you have two tables, Projects and
ProjectHistory, in a Microsoft Access database. The first contains general information
about a project and the second contains details on the progress of a project. For the
purposes of the code, the Project table has at least three fields: ProjectName, ProjectId,
and LastUpdated. It also has an index called Subject on the ProjectName field. The
ProjectName corresponds to the Subject field of an Outlook JournalItem. The
ProjectHistory table requires the fields ProjectId (the foreign key), DetailDateTimeStamp,
and DetailDuration.
The UpdateProjectHistory procedure is passed the name of a project.
(Note that the name of a project must correspond to a subject in an Outlook JournalItem.)
It opens the Journal folder and retrieves just the items for that project using the Restrict
method of the JournalItems collection. It then checks to see if the name passed to
it is in the Projects table. If the project is new, the project name won't be found,
so it adds the project to the table.
Next it retrieves the date from the projects LastUpdated field and stores it in dteUpdated. If it does not find a date, it
assigns 1/1/95 to dteUpdated, which insures that all the JournalItems will
be seen as new (assuming there are no JournalItems older than 1/1/95). Next it
iterates through these items. If a JournalItem has a CreationTime greater
than the projects LastUpdated date, then the information in this item is added as a new
record in the ProjectHistory table.
AccSamp.mdb contains the sample code as well as the two tables needed to run this
solution. The code is found in the modProjectHistory module. To run the code, click Update
Project in the Samples form. When prompted for project, use a name from the Subject
field of your Journal.
Note The use this code from a Microsoft Access module, you must reference the
Microsoft Outlook 8.0 Object Library.