I am trying to get Access to put an appointment onto another person's calendar in outlook. I have a form that you choose who you want to add the appointment to, however, when the code searches for the Mailbox for the person selected it can not find it.
Pleae note that I am relatively new to VBA for Access
The code I am using is below...most of which I have goten off this website and a few others.
Dim outObj As New Outlook.Application
Dim outNS As Outlook.NameSpace
Dim outFolders As Outlook.MAPIFolder
Dim outSubFolders As Outlook.MAPIFolder
Dim outAppt As Outlook.AppointmentItem
Dim strMail, strFirst, strLast As String
Dim intCount As Integer
Dim frm As Form
' Save record first to be sure required fields are filled.
' Exit the procedure if appointment has been added to Outlook.
Set frm = Screen.ActiveForm
If frm.AddedToOutlook = True Then
MsgBox "This appointment already added to Microsoft Outlook"
'Set the name of the Mailbox
strMail = frm.Auditor.Text
intCount = InStrRev(strMail, " ")
strFirst = Trim$(Left$(strMail, intCount))
strLast = Trim$(Right$(strMail, intCount))
strMail = "Mailbox - " & strLast & ", " & strFirst
' Add a new appointment.
Set outNS = outObj.GetNamespace("MAPI")
Set outFolders = outNS.Folders(strMail)
Set outSubFolders = outFolders.Folders("Calendar")
Set outAppt = outObj.CreateItem(olAppointmentItem)
.Start = frm.ApptDate & " " & frm.ApptTime
.Duration = frm.ApptLength
.Subject = frm.Appt
If Not IsNull(frm.ApptNotes) Then .Body = frm.ApptNotes
If Not IsNull(frm.ApptLocation) Then .Location = _
If frm.ApptReminder Then
.ReminderMinutesBeforeStart = frm.ReminderMinutes
.ReminderSet = True
' Release the Outlook object variable.
Set outObj = Nothing
' Set the AddedToOutlook flag, display a message.
frm.AddedToOutlook = True
MsgBox "Appointment Added!"
MsgBox "Error " & Err.Number & vbCrLf & Err.Description