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.
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
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
Regards,
John