Retieve Outlook data from Access (1 Viewer)

JohnPapa

Registered User.
Local time
Today, 23:10
Joined
Aug 15, 2010
Messages
954
It's been some time since I wrote the following, which takes a string made up of "Lastname Firstname Telephone" and writes it at a specific time in Outlook. It uses Late binding so it works across all Oulook versions.

Code:
Public Function funOutputAppointmentToOutlook(dtmDate As Date, strSubject As String)
 Dim olApp As Object
Dim mNameSpace As Object
 
Const olFolderCalendar = 9
Const olAppointmentItem = 1
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
 
If Err.Number = 429 Then
     Err.Clear
      'Outlook is not running; open Outlook with CreateObject
      Set olApp = CreateObject("Outlook.Application")
End If
 
Set mNameSpace = olApp.GetNamespace("MAPI")
 
Dim olApt As Object
Set olApt = olApp.CreateItem(olAppointmentItem)
 Set olApt = olApp
 ' Add the Form data to the Appointment Properties
With olApt
    .Start = dtmDate
    .duration = 1
    .Subject = strSubject
    .Save
End With
 Set olApt = Nothing
Set mNameSpace = Nothing
Set olApp = Nothing
End Function
I would like to first check the specific Outlook time slot whether the string exists already and only if it does not exist to write it. It's been a while, so if someone can provide a hint it would be helpful.

Regards,
John
 

JohnPapa

Registered User.
Local time
Today, 23:10
Joined
Aug 15, 2010
Messages
954
It appears that I got what I wanted by adding one line of code to my original code
Between the two lines which appear in my code above
Code:
.Subject = strSubject    
 .Save

I added
Code:
CreateObject("Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(9).Items(strSubject).Delete

Folder 9 is the Calendar Folder.
John
 

Users who are viewing this thread

Top Bottom