Create Outlook meeting request via VBA

Posted on 2011-10-12
Last Modified: 2012-05-12
In the application I'm working on, there is a section for users to create "milestones" for an activity.  Some of these milestones, when created or edited, need to be entered in Outlook as a meeting request, and sent to a group of individuals who are assigned to that activity.  Code in the same section also creates or modifies data stored in a common SharePoint calendar.

I found some sample code (below) in this question and modified it as below.  
Public golApp As Outlook.Application
Public golNameSpace As Outlook.NameSpace

Function Initialise_Outlook() As Boolean
On Error GoTo Init_err
Set golApp = New Outlook.Application
Set golNameSpace = golApp.GetNamespace("MAPI")
Initialise_Outlook = True
Exit Function
Initialise_Outlook = False
Resume Init_Bye

End Function

Function CreateAppointment(MyStartDateTime As Date, MyEndDateTime As Date, _
                           MySubject As String, MyLocation As String, _
                           MyReminder As Boolean, MyBody As String)
Dim objNewAppt As Outlook.AppointmentItem

    ' Set global Application and NameSpace
    ' object variables, if necessary.
    If golApp Is Nothing Then
        If Initialise_Outlook() = False Then
            ' You'll need to handle this error
            ' in your own code.
            MsgBox "Unable to initialize Outlook. "
            Exit Function
        End If
    End If

    Set objNewAppt = golApp.CreateItem(olAppointmentItem)
    With objNewAppt
        .AllDayEvent = False
'        Set MyProp = .UserProperties.Add("MyClass", olText)
'        MyProp.Value = MyClassName
        .Start = MyStartDateTime
        .End = MyEndDateTime
        .Subject = MySubject
'        .Categories = MyCategories
        .ReminderSet = False
        .BusyStatus = olBusy
        .Location = MyLocation
        .Body = MyBody
        If MyReminder = True Then
            .ReminderSet = True
            .ReminderMinutesBeforeStart = 1
        End If

        'add recipients here (obviously not the values I'm actually using)
        .Recipients.Add ""
        .RequiredAttendees = ""
    End With
CreateAppointment = True

End Function

Open in new window

It appears to work, because the appointment is appearing in my calendar, but the recipient is not getting the meeting request.  As a result of the Save and Send actions, I'm getting the following two popups (I assume these have to do with Outlook security).  .save warning .send warningWhen I open the appointment in my calendar, the To box and Required Attendees show the email address of the individual I have entered in the code, but the status bar (above the To: box) says "Invitations have not been sent for this meeting".  I assumed that the .Send method would actually send the message but that does not seem to be happening.  

I am developing this application for a branch of the US govt, and our systems are configured with a custom form which normally pops up whenever we send an email, allowing us to add some classification settings to the message.  This popup is not showing up when the .Send method is executed.

I am unable to implement Redemption as I have multiple users and our IT rules prevent us from installing "unapproved" software.
Question by:Dale Fye (Access MVP)
    LVL 13

    Expert Comment

    LVL 47

    Author Comment

    by:Dale Fye (Access MVP)
    I don't have a problem with the Outlook security dialogs poping up, since this really doesn't happen very often.  I'll take a look at changing the registry setting indicated in the first link.  Not sure whether the IT department has that locked down or not.  Although it would be nice to overcome this issue, the real issue here is why won't the code actually send them meeting request?

    I'm using SendObject to send regular email, and that works (still pops up the 2nd warning shown above), but this code is not sending the meeting request.
    LVL 26

    Expert Comment

    You may want to contact @Helen_Feddema directly as Outlook is her specialty.
    I have had problems with Outlook being unwilling to create and send items for users other than the logged on user
    (i.e. group calendars, assigning tasks to others)

    I did not successfully overcome that, and gave up on the effort.
    I could create and send tasks to the local user, but any attempts to do so with groups or other users looked like it should work.
    Never did.  You had to open the items manually and assign them.
    And it wasn't mission critical, so I gave up on it.
    LVL 47

    Author Comment

    by:Dale Fye (Access MVP)
    Thanks, Nick.  

    If Helen doesn't chime in I'll send her an email off-line.

    BTW, tested changing the registry setting and am unable to do so.

    LVL 11

    Accepted Solution

    Hi Guys,

    There are lots of Outlook coding experts here in addition to Helen (as good as she is!)

    I think you may be missing the

    With objNewAppt
            .MeetingStatus = 1 'appointment is a meeting

    LVL 47

    Author Closing Comment

    by:Dale Fye (Access MVP)
    We have a winner!
    LVL 47

    Author Comment

    by:Dale Fye (Access MVP)
    Adding that one line made all the difference.  Thanks David.

    I thought that putting the app in a trusted location might eliminate the Outlook warnings, but that did not seem to work either.  Will have to pursue getting approval to use Redemption.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    737 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

    16 Experts available now in Live!

    Get 1:1 Help Now