How do I create a Meeting on the non default calendar of the non default email address in outlook using VBA code?
The code that I have creates the invites in the def
This code will create a Appointment on non default calendar in a non default account in Outlook. Hope this helps someone else out in future:
Sub Whatever()
Dim olApp As Object
Set olApp = GetObject(, "Outlook.Application")
Dim oApt As Outlook.AppointmentItem
Dim ns As Outlook.Namespace
Dim recip As Outlook.Recipient
Dim oFolder As Outlook.Folder
Set ns = olApp.GetNamespace("MAPI")
Set recip = ns.CreateRecipient("otheremail@contoso.com")
If recip.Resolve Then
Set otherFolder = ns.GetSharedDefaultFolder(recip, olFolderCalendar)
End If
Set oApt = otherFolder.Items.Add(olAppointmentItem)
oApt.MeetingStatus = olMeeting
With oApt
.Subject = "Test"
.Start = "15/04/2019 09:00"
.End = "15/04/2019 09:10"
.Location = "The Business Meeting Room"
.Recipients.Add ("user@contoso.com")
.Send
End With
End Sub