Create Outlook meeting request via VBA

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.
LVL 50
Dale FyeAsked:
Who is Participating?
DavidT543Connect With a Mentor Commented:
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

Dale FyeAuthor Commented:
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.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.
Dale FyeAuthor Commented:
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.

Dale FyeAuthor Commented:
We have a winner!
Dale FyeAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.