Private Sub Meeting_Invite_Shared_Mailbox()
Dim olApp As Outlook.Application
Dim outNameSpace As Namespace
Dim outSharedName As Outlook.Recipient
Dim outCalendarFolder As MAPIFolder
Dim olAppItem As Outlook.AppointmentItem
Dim SharedMailboxEmail As String
SharedMailboxEmail = "DSSTest@companyname.com"
Set olApp = GetObject("", "Outlook.Application")
On Error GoTo 0
If olApp Is Nothing Then
On Error Resume Next
Set olApp = CreateObject("Outlook.Application")
On Error GoTo 0
If olApp Is Nothing Then
MsgBox "Outlook is not available!"
Exit Sub
End If
End If
Set outNameSpace = olApp.GetNamespace("MAPI")
'Start at Namespace and get the DSSTest/DSSTest@companyname.com data file folder (whichever works)
'Either
Set outCalendarFolder = outNameSpace.Folders("DSSTest")
'or
Set outCalendarFolder = outNameSpace.Folders("DSSTest@companyname.com")
'Get the calendar within DSSTest/DSSTest@companyname.com
Set outCalendarFolder = outCalendarFolder.Folders("Calendar")
'Confirm correct calendar
Debug.Print outCalendarFolder.Name, outCalendarFolder.FolderPath
'Create new appointment in DSSTest calendar
Set olAppItem = outCalendarFolder.Items.Add(olAppointmentItem)
With olAppItem
' set default appointment values
.Location = "XXXX"
.ReminderSet = True
.BusyStatus = olBusy
.RequiredAttendees = "XXXX"
.MeetingStatus = olMeeting
On Error Resume Next
.Start = Date
.Duration = 60
.Subject = "Subject"
.Body = "Body text"
.ReminderSet = True
.ReminderMinutesBeforeStart = 15
.BusyStatus = olBusy
On Error GoTo 0
.Display ' saves the new appointment to the default folder
End With
End Sub