Access VBA to add calendar appointment to 2nd calendar under 'My calendars" (1 Viewer)

scotwithadevil

New member
Local time
Today, 21:35
Joined
Jul 13, 2013
Messages
9
Hi
I have written some code to add an appointment item. I have 2 calendars under 'My Calendars': my personal one and a second one named 'Brokerage'. My code is currently adding the appointment to my default calendar but I want it to add it to my second calendar.
This is the code I am using:

InviteBody = "This is to remind you that you are booked to attend the above training course. " & vbCrLf
InviteBody = InviteBody & "If you are unable to attend this course, you MUST inform us by emailing "
InviteBody = InviteBody & CalendarFrom & " "
InviteBody = InviteBody & "to advise us you can no longer attend. " & vbCrLf & vbCrLf
InviteBody = InviteBody & "This calendar invite is for your information only and we DO NOT monitor Accept/Decline calendar invite responses. " & vbCrLf & vbCrLf
InviteBody = InviteBody & "You may wish to change the status of this calendar entry to busy."

Set outInvite = Outlook.CreateItem(olAppointmentItem)
'Set outInvite = MyFolder2.Items.Add("IPM.Appointment")
outInvite.MeetingStatus = olMeeting
outInvite.Subject = Me.CourseName
outInvite.Importance = 2 ' high
outInvite.BusyStatus = 0 ' free (you don't want your own calendar to show tentative or busy)
outInvite.Location = Me.Venue
outInvite.Start = Me.StartDate & " " & Me.StartTime
outInvite.End = Me.StartDate & " " & Me.EndTime
outInvite.RequiredAttendees = InviteList
outInvite.Body = InviteBody
outInvite.ResponseRequested = False
outInvite.ReminderMinutesBeforeStart = 1440
outInvite.Send 'Uncomment if you want invitations sent immediately, rather than just setting up (but not sending)a new meeting request in your calendar
'outInvite.Save 'Uncomment if you want message saved to your sent items folder
Set outInvite = Nothing
ConfirmMsg = "Emails and Calendar Invites have been created but not sent."

Can anyone tell me how to change the code so it writes to the second calendar under 'My Calendars' please?.
I don't know a huge amount of VBA - most of the code I have used is as a result of spending hours ploughing through google.

Many thanks (just in case there is someone out there kind enough to help me)
 

scotwithadevil

New member
Local time
Today, 21:35
Joined
Jul 13, 2013
Messages
9
Problem solved.
I added the following code:
Set olfolder = ouApp.GetNamespace("MAPI").PickFolder

Set outInvite = olfolder.Items.Add


This displays the Outlook folder listing and then I can just select the calendar I want the appointment to go into.
 

Users who are viewing this thread

Top Bottom