Working with Outlook calendar (appointment and meeting items)
Yeah sure, email is front and center with Outlook. But right behind it and ready to steal the show is the Outlook calendar. If you aren’t looking at email, I bet you are looking at your calendar to see if you can meet at such-and-such time on such-and-such date. It is my opinion that, the appointments residing in our calendar are the culmination of all your emailing efforts.
If you didn’t email, you wouldn’t have appointments.
–AND—
If you didn’t have appointments, you’d have nothing to email about.
Today, let’s take a look at how work with the items in your Outlook calendar:
- What is an Outlook Calendar item?
- How to enumerate calendar items
- How to create calendar items
- How to list attendees and see their response status
- How to delete calendar items
- How to send meeting responses
- Useful events
What is an Outlook calendar item?
Outlook likes to mix things up and use different objects for different purposes (e.g. Explorer and Inspector windows). When it comes to the calendar we have two items to master:
- AppointmentItem :: this is the appointment object that resides in a calendar folder. You can create this via code.
- MeetingItem :: this is a meeting request received by the user. It resides in the inbox… tricky! You cannot create these with code, but you can code against them when they exist.
Now, here are some mind-blowing facts about these two objects:
- An AppointmentItem can become a meeting by adding another person to it and clicking Send.
Once sent, the AppointmentItem travels the Interweb is magically turned into a MeetingItem by the time the intended recipient receives it.
- A MeetingItem contains an AppointmentItem.
- An AppointmentItem does not contain a MeetingItem… even if you add another user to it.
I have a few code samples that show the basics of Outlook calendars but also aren’t too lame. In fact, I daresay they are not lame at all as they can be quite useful. I thought of you, my fellow developer, and I want you to steal this code. It will be here when you need it.
How to enumerate calendar items
To make this happen, we’ll work with Outlook appointments residing in the default calendar. The code loops through the folder’s items collection and prints out its message class.
VB.NET code example
Friend Sub EnumerateDefaultAppointmentsAndDoSomethingSillyThatIllustratesAPoint( _ calendarType As String) Dim calendar As Outlook.Folder = Nothing Dim calendarItems As Outlook.Items If calendarType = "AppointmentItem" Then calendar = _ OutlookApp.Session.GetDefaultFolder( _ Outlook.OlDefaultFolders.olFolderCalendar) calendarItems = calendar.Items Else 'MeetingItem (are assume that is the case) calendar = _ OutlookApp.Session.GetDefaultFolder( _ Outlook.OlDefaultFolders.olFolderInbox) calendarItems = calendar.Items End If Dim i As Integer = 0 Do Until i = calendarItems.Count Console.WriteLine(calendarItems.MessageClass) 'AppointmentItem = IPM.Appointment 'MeetingRequest = IPM.Schedule.Meeting.Request Loop 'Release COM Objects! If calendarItems IsNot Nothing Then Marshal.ReleaseComObject(calendarItems) If calendar IsNot Nothing Then Marshal.ReleaseComObject(calendar) End Sub
Okay, this is a somewhat lame except that it makes a nice segue into informing you of the different message classes in play when working with the calendars.
Outlook Item | Message Class |
AppointmentItem | IPM.Appointment |
MeetingItem | IPM.Schedule.Meeting.Response IPM.Schedule.Meeting.Resp.Pos IPM.Schedule.Meeting.Resp.Neg IPM.Schedule.Meeting.Resp.Tent IPM.Schedule.Meeting.Resp.Canceled |
Using the message class, you quickly filter a folder’s items to the objects you desire. This strategy helps ensure you access only the item types you want… reducing the potential for error. I’ll show you this technique soon.
How to create calendar items
I stated previously that you can only create AppointmentItems with code (and that you can’t create MeetingItems)… and it’s true. Here is how it’s done:
Friend Sub CreateAppointment(title As String) Dim apptItem As Outlook.AppointmentItem = Nothing apptItem = _ OutlookApp.Session.Application.CreateItem( _ Outlook.OlItemType.olAppointmentItem) With apptItem .Subject = title .Start = DateTime.Now .End = Date.Now.AddHours(1) .Save() End With 'Release COM Objects If apptItem IsNot Nothing Then Marshal.ReleaseComObject(apptItem) End Sub
First we use the CreateItem method to create the AppointmentItem. Then we set a few properties and save it. Done.
How to create a recurring appointment (as a reminder)
This sample kills two birds with one stone. Here, I show you how to create recurring appointment as well as how to set a reminder in Outlook.
Creating a recurring appointment is a bit more involved than you might think it would be. This situation is due to the fact that you need to create a ReccurancePattern object for the appointment. To add a reminder to the appointment, we need to set its ReminderSet property to true.
VB.NET code example
Friend Sub CreateRecurringAppointmentWithReminder(reminderText As String, _ recurring As Boolean) Dim apptItem As Outlook.AppointmentItem = Nothing apptItem = _ OutlookApp.Session.Application.CreateItem( _ Outlook.OlItemType.olAppointmentItem) Dim pattern As Outlook.RecurrencePattern = Nothing With apptItem .Subject = reminderText .Importance = Outlook.OlImportance.olImportanceHigh .Sensitivity = Outlook.OlSensitivity.olPrivate .Start = DateTime.Now .End = Date.Now.AddHours(1) .ReminderMinutesBeforeStart = 15 .ReminderSet = True If recurring Then pattern = .GetRecurrencePattern() pattern.RecurrenceType = Outlook.OlRecurrenceType.olRecursDaily pattern.PatternStartDate = DateTime.Parse(Today().ToString) pattern.PatternEndDate = DateAndTime.DateAdd(DateInterval.Day, 14, Today()) pattern.StartTime = .Start pattern.EndTime = .End End If .Save() End With 'Release COM Objects! If pattern IsNot Nothing Then Marshal.ReleaseComObject(pattern) If apptItem IsNot Nothing Then Marshal.ReleaseComObject(apptItem) End Sub
After creating the AppointmentItem and setting some typical properties, we move create the reminder (ReminderSet = True) and the Recurrence pattern. The appointment will recur everyday from the start and will end fourteen days later. Save and release objects… done!
How to create a meeting invitation
A meeting invitation is an AppointmentItem with attendees. We make this happen by adding recipient objects to an AppointmentItem:
Friend Sub CreateAppointmentWithAttendees(meetingTitle As String, meetingDate As String, _ startTime As String, endTime As String, recipientEmail As String) Dim apptItem As Outlook.AppointmentItem = Nothing Dim recipient As Outlook.Recipient = Nothing If IsDate(meetingDate) And IsDate(startTime) And IsDate(endTime) Then apptItem = _ OutlookApp.Session.Application.CreateItem( _ Outlook.OlItemType.olAppointmentItem) recipient = apptItem.Recipients.Add(recipientEmail) recipient.Type = CType(Outlook.OlMeetingRecipientType.olRequired, Integer) With apptItem .MeetingStatus = Outlook.OlMeetingStatus.olMeeting .Subject = meetingTitle .Start = DateTime.Today & " " & startTime .End = DateTime.Today & " " & endTime End With If apptItem.Recipients.ResolveAll Then apptItem.Send() Else apptItem.Display() End If 'Release the COM! If recipient IsNot Nothing Then Marshal.ReleaseComObject(recipient) If apptItem IsNot Nothing Then Marshal.ReleaseComObject(apptItem) End If End Sub
I chose to make this procedure "steal-able" by adding parameters. I check to ensure the date parameters are, indeed, dates before wasting precious CPU cycles. If they are I create the appointment and use the recipientEmail parameter to add a recipient. I also set the MeetingStatus to olMeeting, this is an important thing to do.
I then resolve the recipients and, if it resolves successfully, send it. If it doesn’t resolve, I display to the user so they can deal with it.
How to create all-day event
This is the last example showing you how to create an Outlook appointment. This one shows how to create an all-day event. These events are the ones that reside at the top of the calendar:
To create one of these, you create an appointment and set AllDayEvent to True.
VB.NET code example
Friend Sub CreateAllDayAppointment(eventTitle As String, startDate As String, _ endDate As String) Dim apptItem As Outlook.AppointmentItem = Nothing If IsDate(startDate) And IsDate(endDate) Then apptItem = _ OutlookApp.Session.Application.CreateItem( _ Outlook.OlItemType.olAppointmentItem) With apptItem .Subject = eventTitle .Start = startDate .End = endDate .AllDayEvent = True .Save() End With End If 'Release COM Objects! If apptItem IsNot Nothing Then Marshal.ReleaseComObject(apptItem) End Sub
I realize I could have combined this sample with another but I wanted to point it out specifically.
How to list attendees and see their response status
When you send a meeting invitation, most people are kind enough to send a reply that lets you know if they will attend (or not). But they don’t have to because Outlook lets you approve or reject the meeting without notifying the organizer. This is rude and forces the organizer to open the meeting on their calendar and check to see who will attend.
Well, how about we, as nice developers, provide a feature that informs the organizer the response status of each requested attendee? Pretty good idea right? Well this is exactly what ListAttendees does.
VB.NET code example
Friend Sub ListAttendees(appointment As Outlook.AppointmentItem) If Not IsNothing(appointment) Then Dim recipients As Outlook.Recipients = appointment.Recipients Dim recipient As Outlook.Recipient = Nothing Dim i As Integer = 0 Do Until i = recipients.Count MessageBox.Show(recipient.Name & " :: Meeting Status = _ " & recipient.MeetingResponseStatus) i = i + 1 Loop 'Release the COM! If recipient IsNot Nothing Then Marshal.ReleaseComObject(recipient) If recipients IsNot Nothing Then Marshal.ReleaseComObject(recipients) End If End Sub
This snippet uses the passed AppointmentItem and grabs its Recipients collection. Next it loops through the collection and displays each Recipient object’s MeetingResponseStatus.
Useful? Yes. Slightly annoying to show a message box for each recipient? Absolutely!
How to delete calendar items
If you create items, you will want to delete items. The DeleteAppointmentItems procedure takes care of unwanted appointments. To me, unwanted appointments are any that list me as an optional attendee. Delete them! Delete them all!
VB.NET code example
Friend Sub DeleteAppointmentItems(attendeeName As String) Dim folder As Outlook.Folder Dim folderItems As Outlook.Items Dim filteredItems As Outlook.Items Dim appt As Outlook.AppointmentItem folder = OutlookApp.ActiveExplorer.CurrentFolder If folder.DefaultItemType = Outlook.OlItemType.olAppointmentItem Then folderItems = folder.Items filteredItems = folderItems.Restrict("[MessageClass] = 'IPM.Appointment'") Dim fRemoved As Boolean = False Dim i As Integer = 1 Do Until i > filteredItems.Count appt = filteredItems.Item(i) Dim optionalAttendees As String = appt.OptionalAttendees If Not optionalAttendees Is Nothing Then If optionalAttendees.Contains(attendeeName) Then filteredItems.Remove(i) fRemoved = True End If End If If fRemoved Then 'We removed an item which lowers the items count. 'Leave i as is (i=i) 'reset boolean fRemoved = False Else i = i + 1 End If Marshal.ReleaseComObject(appt) Loop 'Relase COM Objects! Marshal.ReleaseComObject(filteredItems) Marshal.ReleaseComObject(folderItems) Marshal.ReleaseComObject(folder) End If End Sub
To make it (even more) useful, I parameterized the routine so you can pass a name to use as the search criteria. The routine does this:
- References the default calendar folder.
- Filters the folder’s items collection to ensure we work only with the AppontmentItem.
- Loops through the OptionalAttendees collection and looks for the passed name.
- If it finds a match… it deletes the appointment.
Gone! Hello free time! They won’t miss you anyway… you’re optional.
How to send meeting responses
I mentioned earlier that some people send meeting responses some don’t. Some might receive a bunch and want to process their replies in bulk. This is the scenario I have in mind for the SendMeetingResponses routine.
VB.NET code example
Friend Sub SendMeetingResponses(planToAttend As Boolean) Dim inbox As Outlook.Folder = Nothing Dim meetingItems As Outlook.Items = Nothing Dim filteredItems As Outlook.Items = Nothing Dim typeFilter As String = "[MessageClass] = 'IPM.Schedule.Meeting.Request'" inbox = OutlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox) meetingItems = inbox.Items filteredItems = meetingItems.Restrict(typeFilter) If filteredItems.Count > 0 Then Dim i As Integer = 1 Do Until i > filteredItems.Count Dim mtgReqItem As Outlook.MeetingItem = _ CType(filteredItems.Item(i), Outlook.MeetingItem) Dim mtgItem As Outlook.MeetingItem = Nothing Dim apptItem As Outlook.AppointmentItem = _ mtgReqItem.GetAssociatedAppointment(True) If Not IsNothing(apptItem) Then If planToAttend Then mtgItem = _ apptItem.Respond(Outlook.OlMeetingResponse.olMeetingAccepted) mtgItem.Send() Else mtgItem = apptItem.Respond(Outlook.OlMeetingResponse.olMeetingDeclined) mtgItem.Send() End If End If If Not mtgItem Is Nothing Then Marshal.ReleaseComObject(mtgItem) If Not mtgReqItem Is Nothing Then Marshal.ReleaseComObject(mtgReqItem) End If If Not apptItem IsNot Nothing Then Marshal.ReleaseComObject(apptItem) i = i + 1 Loop 'Delete all MeetingRequests now Do Until 1 > filteredItems.Count 'Always use Index =1 because each remove lowers the count '1 is always valid. filteredItems.Remove(1) Loop End If 'Release the COM! If filteredItems IsNot Nothing Then Marshal.ReleaseComObject(filteredItems) If meetingItems IsNot Nothing Then Marshal.ReleaseComObject(meetingItems) If inbox IsNot Nothing Then Marshal.ReleaseComObject(inbox) End Sub
MeetingItem objects reside in the inbox. They are not in calendar folders. Therefore, this routine rummages in the inbox folder and grabs its Items collection.
With the collection in-hand we filter to include only meeting requests. Predictably, next comes “The Loop”. For each Outlook meeting request, we do as directed by the planToAttend parameter and send the response. Before ending, the routine deletes the meeting requests from the inbox.
No more clicking each meeting and responding individually. No sir, we can now blindly accept or reject them and get them off our To Do list.
Useful events
Unlike mail item, appointments don’t have any events specific to them. But, I think the Outlook Application’s ItemSend event is useful. Keep in mind that for Outlook events, you need to an AdxOutlookEvents object to the AddInModule.
ItemSend
No surprise here, this event occurs when an item is sent… either by the user clicking the Send button in an Inspector or by calling the item’s Send method. It’s a great way to automatically include a signature line…
Private Sub adxOutlookEvents_ItemSend(sender As Object, e As ADXOlItemSendEventArgs) _ Handles adxOutlookEvents.ItemSend e.Cancel = False Dim mtgItem As Outlook.MeetingItem = TryCast(e.Item, Outlook.MeetingItem) If mtgItem IsNot Nothing Then mtgItem.Body = "I'LL BRING THE DONUTS!!!" mtgItem.Save() End If End Sub
Everybody likes the guy that brings the donuts to the meeting. You want be that guy (or girl, I don’t mean to be sexist but I hate gender neutral writing).
***
We’ll stop here. I’ve only begun to scratch the surface. Because it’s enough to cover the basics and get you going with Outlook calendars I’ll hold back and save something for next time.
Outlook 2013 add-in development in Visual Studio 2012 for beginners
- Part 1: Outlook add-in development: Outlook Application and base objects
- Part 2: Creating custom Outlook views
- Part 3: Creating custom Outlook forms
- Part 4: Outlook UI – Explorer and Inspector Windows. What is customizable?
- Part 5: Customizing Outlook main menu, context menus and Backstage view
- Part 6: Creating custom Outlook ribbons and toolbars
- Part 7: Advanced view regions for Outlook 2013 – 2003
- Part 8: Advanced form regions for Outlook 2013 – 2003
- Part 9: Working with Outlook Accounts, Stores, Folders and Items
- Part 10: Working with Outlook calendar
- Part 11: Working with Outlook tasks
42 Comments
shouldn’t the code at the end of your examples be:
if xxxx is NOT nothing then Marshal.ReleaseComObject( xxx ) ??
You are correct. I have updated the code samples.
Thanks for letting me know.
Ty
Should this code be part of some addin(Particularly the send event code) or should it be part of some macro? That part is not explained here.
Hi Partha,
Yes, this code should be in an Add-in Express based Outlook add-in. The entire “Outlook 2013 add-in development” series is devoted to developing add-ins for Microsoft Office Outlook.
Hello, love the information on the site and wish I had found it sooner! I have been struggling with the best way to do this. Basically, I am trying to make an Online Meeting Outlook calendar invite. The part I am stuck on is making it an online meeting that includes the Lync link and dial in info. I have tried making myMeeting.OnlineMeeting = true. That didn’t do anything.
Our company uses Lync for its online meeting option. It does appear that since the Lync Online Meeting option itself is a COM add in I should be able to call it somehow?
Having a real tough time with this one. Any advice you have would be a huge help.
Thanks in advance!
Mike
Hi Mike,
I think I understand what you are trying to do.
I also think how you are trying to do it makes sense.
That said, I don’t see the OnlineMeeting property in the MeetingItem documentation:
https://msdn.microsoft.com/en-us/library/office/ff868714(v=office.15).aspx
This means it is no longer a supported property.
As for accessing the Lync Outlook addin…that might be worth trying but I think a simpler idea would be to take the meeting information produced by the adding when you click the Lync Meeting button and use it to create online meetings.
I did some testing on my account and the Lync information was the same every time I click the Lync Meeting button.
Would this work for your purposes?
Ty
Hello Ty, Thanks for responding. For security reasons they set up our Lync accounts to create unique meeting details each time we schedule an online meeting so we can’t use the same Lync link for each one.
Is calling that addin possible from VBA?
I also see Office Communicator library in VBA but in that I dont see anything that would be for creating an online meeting. Only for having Lync conversations.
Thanks again
Mike
Hi Mike,
Regarding Lync automation, I’m not an expert.
I did some digging (research) and found some code samples on MSDN:
Lync 2013 Code Sampes
This sample looks like the best place to start.
Ty
Thanks Ty,
I will have another look at the SDK. It was a bit over my head but that might be the next place I go.
In the meantime I am considering calling a COMAddIn, which is the Lync Online Meeting. Here is the section of my code that I have after the meeting invite is successfully created:
Dim addIn As COMAddIn
Dim LyncObject As Object
Set addIn = Outlook.Application.COMAddIns.Item(“UCAddin.UCAddin.1”)
Set LyncObject = addIn.Object
‘ This is just an IF to confirm the addin is connected, which always come up true.
If addIn.Connect = True Then
MsgBox “it is Connected” & addIn.ProgId
Else
MsgBox “Not Connected”
End If
‘this is where I should be able to call the COM Add In, right? I can’t figure out what piece of code this should be to trigger the COM Add In. How can I get this?
End Sub
This is how a COMAddIn Should work right? Am I completely off base?
Thanks again Ty. This is my one last piece for this whole thing to be finished. So close!!!!
Mike
Sorry for all the posts, but I think I’ve found out the way. In VBA I have now added the “Office Communicator W 14 Type Library” reference library. This is the Lync .dll file for Outlook Online Meeting Addin.
With this I have now gone to the VBA Object Viewer and I have access to several methods specific to making online meetings. Specifically, CreateNewUCMeeting and MakeOnlineMeeting. Unfortunately I dont’t have any documentation on how exactly to type this out. So far I am getting only errors.
Thanks Ty,
Mike
Hi Mike,
I think this might be just what you need:
https://stackoverflow.com/questions/24531637/how-to-call-makeonlinemeeting-outlook-vba
From the looks of it, all you need to do is pass an AppointmentItem to it.
Ty
No such luck with:
MakeOnlineMeeting (myItem)
I still keep getting an error saying “Sub or Function not defined”. It must be defined as I have selected the library for this addin. Thanks for all your help. If you come across anything that might help please let me know!!!
Mike
Thanks Mike, I’ll keep looking as this is an interesting problem and you’d think a straight-forward method exists.
Please update me if you have any results on your side.
Ty
Good afternoon,
Of Excel you want to create an appointment in the general calendar, to be seen all
users are connected to a common calendar say Obschiy_ kalendar.ics
In your default calendar I can add this meeting without any problems described in the article code, but how to persuade VBA select a different calendar? not think.
Lev,
You can move an appointment item to another folder by using the Move method:
https://msdn.microsoft.com/en-us/library/office/ff862723%28v=office.15%29.aspx
The delete based on filtered items works great on my dev box as an admin user, but not on users boxes. I am using a public calendar and filtering based on the Mileage value I add to the outlook calendar appointment when I create the calendar event (programmatically). I might have multiple events, so here is my code… can you tell me what I am missing? VS 2010 – 64 bit Windows 7 machines with Outlook 2010.
Private Function DeleteFromCalendarFromTS_MultipleDeletes(ByVal NewUniqueID As String, ByVal UserID As Integer, ByVal Dt As Date) As Boolean
Try
‘Pull the Vacations for this month
Dim user = New SimpleUser(UserID)
‘If (user.DeptPublicFolderName.Length > 0) Then ‘ ONly read the calendar if one is assigned
Using pf As New AFLOutlook(OutlookActivityType.PubFolders)
Dim PCFolder As MAPIFolder
‘Dim ApptItem As AppointmentItem
‘Dim folderItems As Items
Dim filteredItems As Items
Dim myItems As Items
Dim sFilter As String
‘ read the calendar and create a collection of items
PCFolder = pf.ReadPublicCalendar()
myItems = PCFolder.Items
myItems.IncludeRecurrences = False
‘https://www.add-in-express.com/creating-addins-blog/outlook-calendar-appointment-meeting-items/#delete
sFilter = “[Mileage] = “”” + NewUniqueID + “”””
filteredItems = myItems.Restrict(sFilter)
Dim fRemoved As Boolean = False
Dim i As Integer = 1
Do Until filteredItems.Count = 0
filteredItems.Remove(1)
‘Marshal.ReleaseComObject(ApptItem)
Loop
‘Relase COM Objects!
Marshal.ReleaseComObject(filteredItems)
‘Marshal.ReleaseComObject(folderItems) ‘ <– This generated an err
Marshal.ReleaseComObject(PCFolder)
End Using
Catch ex As System.Exception
MessageBox.Show("Eror in " + Reflection.MethodInfo.GetCurrentMethod().Name + " Error: " + ex.Message)
End Try
Return True
End Function
–Here is my "ReadPublicCalendar() (C# method in another module):
public MSOutlook.MAPIFolder ReadPublicCalendar()
{
MSOutlook.MAPIFolder fldHIT;
MSOutlook._Application olApp = new MSOutlook.Application();
MSOutlook._NameSpace olNS = olApp.GetNamespace("MAPI");
MSOutlook._Folders oFolders;
oFolders = olNS.Folders;
MSOutlook.MAPIFolder oAllPFolder = (MSOutlook.MAPIFolder)olNS.GetDefaultFolder(MSOutlook.OlDefaultFolders.olPublicFoldersAllPublicFolders);
fldHIT = oAllPFolder.Folders["PublicCalFolderName"].Folders["PubCal"];
return fldHIT;
}
I solved my issue — I was chasing a ghost — a previously deleted event. Luckily I track all my deletions by event ID and was able to write a sproc to delete any old deleted events and problem solved.
Thanks for a great article… It solved my issue (even if I didn’t realize it right away).
Hello – I am looking for some help in automating the editing of meeting invites body (sent by others).
Essentially,
if meeting invite, then at the end of the text in body, add “a string”.
Do this for all future instances already in the calendar/Inbox
Put a script to put this edit on ANY future invites I receive.
Can you please help me with the code? Thank you!
PS: I am a user in a large corporate. I do NOT have admin access to Exchange server
Hello Eddie,
Please check https://social.msdn.microsoft.com/Forums/office/en-US/78c206d0-9fd0-4e7a-8d62-e79689b74fb4/c-adding-hyperlink-in-appointment-item-of-outlook?forum=outlookdev.
Hi,
I am new to working with Outlook using VB.net and have read this article and it is really what i have been looking for, however how do you set up the connection to outlook/exchange server to get the users calendar? not sure if i missed one of the initial posts which discussed this?
Thanks
Hello Hayleigh,
> how do you set up the connection to outlook/exchange server to get the users calendar?
This isn’t discussed anywhere because Outlook hides the process so that you only see an Outlook calendar folder, which is a result of this process. The blog describes dealing with items stored in such a folder.
Hi, It was a good article for the beginners like us. I need to know whether we can able to get the time zone of the recipient in outlook calendar? P
Hello ManiKandan,
There’s no time zone associated with a contact. Outlook has two areas related to time zones: 1) Application.TimeZones; this collection reflects the data stored in the Windows registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones; 2) AppointmentItem (it represents appointments and meetings) provides the StartTimeZone and EndTimeZone properties.
Thanks Andrei, First of all Thanks for your reply, As you are the only person responded to my query :), If my understanding is right then using MAPI we cannot retrieve recipient timezone as AppointmentItem’s StartTimeZone & EndTimeZone properties are used while booking the appointment. Correct me if i am not right.
I can only talk about the Outlook object model. I don’t know what data are stored in the underlying MAPI properties. Most probably, there’s no time zone related data in MAPI properties associated with a recipient. I won’t be surprised however if you find some related object providing such data. But frankly, I just don’t know.
Okay Thanks for your prompt response.:)
For Outlook automation to be very useful to me, I would want a way to be able to programatically examine a person or resource in the contact list and determine if they are available (or busy) during a specific date & time interval. In other words, you want to schedule a meeting, for example, and determine if the desired attendees are free at a proposed date & time. This is done manually all the time with Outlook. I think the mechanism would be to read publicly accessible calendar information from a given contact. But, I haven’t found any documentation or examples that indicate that this can be done programatically. Can it?
Hello Mark,
Search for “GetFreeBusy” at https://msdn.microsoft.com/en-us/library/cc513843(v=office.12).aspx; other info on that page might be of interest to you. The method itself is described at https://msdn.microsoft.com/VBA/Outlook-VBA/articles/addressentry-getfreebusy-method-outlook. See also https://msdn.microsoft.com/VBA/Outlook-VBA/articles/recipient-freebusy-method-outlook.
I need to post a meeting that occurred in the past on my Outlook calendar for auditing purposes. Every time I try to propose the meeting that occurred this morning, a message appears stating the meeting cannot be scheduled because it occurred already. Any workaround? Thank you.
Hello Pamela,
I can’t reproduce this issue using this VBA macro in Outlook 2016:
Sub createMeeting()
Dim appt As Outlook.AppointmentItem
Set appt = Application.CreateItem(olAppointmentItem)
appt.Subject = “subject”
appt.Start = #9/28/2010 8:00:00 AM#
appt.MeetingStatus = olMeeting
appt.Recipients.Add “{a contact name here}”
appt.Save
End Sub
I don’t see the meeting added to my calendar though. Does your question relates to using the Outlook object model in your program? If so, please provide some code. Otherwise, I suggest that you ask your question at answers.microsoft.com.
Hello Andrei,
Is there any way to change the Appointment organizer? I am trying to create som outlook appointments, from a c# windows forms app, but they appear with my name as the organizer. I want to change the organizer to the formation account for example.
Thank’s in advance.
Jorge Lafuente
Hello Jorge,
Please have a look at https://social.msdn.microsoft.com/Forums/en-US/304a4e4f-afa8-4b57-97c4-f632e7b4e50f/to-create-appointmentitem-with-different-than-current-organizer?forum=outlookdev.
You can also create a meeting request using an Outlook add-in running in the account of the organizer. Your app can communicate with the add-in by calling a public method on the add-in via {an Outlook.Application}.COMAddins.Item(strYourAddinProgId).Object.YourMethodOrProperty.
Hi,
To the usefull events in Appointment, how about a few lines on appointment changed, to catch this event, as well as reading user defined appointment variables
Hello Walter,
Please check PropertyChange and CustomPropertyChange sections at https://www.add-in-express.com/creating-addins-blog/creating-custom-outlook-forms/.
How would I programatically check if an already appointment exists before creating it or how would I check if there was already an existing (same) appointment before moving it to a an Outlook folder?
Thanks in advance
Hello Shammik,
You seem to assume that only one appointment can be created for a given date/time. This isn’t so. If you are going to create an appointment so that it doesn’t intersect with an existing appointment, you should use Items.Restrict() or Items.Find() to get the list of appointments which fit the date interval that you pass to these methods. At https://www.add-in-express.com/creating-addins-blog/outlook-newmail-custom-solution/, you can see how we use Items.Restrict() to find items received.
I’m new to scripting/coding and want to create a vba script for outlook 2016. I want to be able to color code my calendar based on declined meeting invites to other people such as if one person declines show as yellow on calendar, if two or more people decline show as purple and if all decline show as red in calendar.
Can you provide some assistance with this issue?
Hello Alex,
The Outlook object model doesn’t provide a way to achieve this.
Consider categorizing the items. In my Outlook version 1912 the color of the last category added to an appointment item is used to colorize the item in the Calendar view. You can create a category of the required color; see https://docs.microsoft.com/en-us/office/vba/api/outlook.category.
Hello,
I’m trying to get the example from above to work, How to list attendees and see their response status. When I paste the code into vba in outlook I get a lot of red txt and the error only valid in object module when I hit Debug>Compile.
Am I missing some additional files or code to make this work?
Thanks,
Alex
Hello Alex,
The code above is written in VB.NET, not in VBA.
Bonjour,
J’adore votre travail ! Merci bien pour ce partage. J’ai néanmoins une question. Pour un RDV que je souhaite mettre en couleur par “catégories” et en status privé j’ai trouvé ces codes mais ça ne fonctionne pas.
Avez-vous une idée ? Je vous remercie par avance, Céline
.Categories = “Conges” Ne fonctionne pas
.BusyStatus = olOutOfOffice ????
.ReminderSet = True ?????
.Sensitivity = olConfidential ????
Hello Céline,
I’ve used Google Translate to translate your message to English; you can use Google Translate, too.
Setting BusyStatus:
.BusyStatus = Outlook.OlBusyStatus.olOutOfOffice
Setting ReminderSet:
see the blog above
Setting Sensitivity:
see the blog above
In my case I type “=” and Visual Studio suggests my options.
As to Categories, it is a simple string property. In what way it doesn’t work?