I'm working on an Access 2K3 database that writes calendar appointments to an e-mail/groupware app called Mirapoint. But I can't write directly to the Mirapoint server (long story, but bottom line, it's a web-based appliance with no API) - so I have to write the appointments to Outlook, then synchronize the calendar with an Outlook add-in called SynQ. The SynQ add-in appears in the Outlook client under the "Tools" menu on the main menu bar. My first idea was to create an instance of Outlook and invoke the SynQ command after the appointment is written, so it gets to the server immediately with no user intervention. Here's the code I'm using:
The code breaks on the highlighted line with "Error 5: Invalid procedure call or argument".
Does anyone know how to do this? Thanks!
Ken S.
Code:
Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim myNameSpace As Outlook.NameSpace
Dim myInspector As Outlook.Inspector
Set objOutlook = CreateObject("Outlook.Application")
Set myNameSpace = objOutlook.GetNamespace("MAPI")
myNameSpace.Logon "xyxyxyxyx", "zyzyzyzyz", False, True
Set objAppt = objOutlook.CreateItem(olAppointmentItem)
Set myInspector = objAppt.GetInspector
With objAppt
.Start = Me!ApptStartDate & " " & Me!ApptTime
.Duration = Me!ApptLength
.Subject = Me!Appt
If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location = Me!ApptLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
End If
.Recipients.Add ("xxxxx@yyyy.zzz")
.Recipients.Add ("yyyyy@zzzz.xxx")
.Save
Me!ApptID = .EntryID
.Close (olSave)
End With
[highlight]myInspector.CommandBars("Menu Bar").Controls("Tools").Controls("Synchronize with SynQ").accDoDefaultAction[/highlight]
Does anyone know how to do this? Thanks!
Ken S.