Adding Appointment from Access to Outlook on Another Persons Calendar

Posted on 2008-06-24
Last Modified: 2013-11-27
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.

Please help,

****CODE START****

Option Explicit

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

Function addAppt()

' Save record first to be sure required fields are filled.

    DoCmd.RunCommand acCmdSaveRecord

' 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"

        Exit Function


'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)

        With outAppt

           .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

           End If


        End With

    End If

    ' Release the Outlook object variable.

    Set outObj = Nothing

    ' Set the AddedToOutlook flag, display a message.

    frm.AddedToOutlook = True

    DoCmd.RunCommand acCmdSaveRecord

    MsgBox "Appointment Added!"

    Exit Function


    MsgBox "Error " & Err.Number & vbCrLf & Err.Description

    Exit Function

End Function

****CODE END****

Open in new window

Question by:BVass
1 Comment
LVL 74

Accepted Solution

Jeffrey Coachman earned 500 total points
ID: 21862893

This Question is almost Identical.
Try the solution:


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This script will sweep a range of IP addresses (class c only, and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now