Here are several encapsulated functions for working with AppointmentItem properties. Instead of inline method calls, I put each method call into its own function.
I did not include sample code for each method. All you need to do is pass a PostItem Object to each function. See NoteItem Properties for sample code you can adapt, and The AppointmentItem Object for various methods of creating AppointmentItem Objects.
Actions collection
Function GetAppointmentItemActions(appt As Outlook.AppointmentItem) As Outlook.Actions Set GetAppointmentItemActions = appt.Actions End Function
AllDayEvent Property
Check the AllDayEvent flag for a given appointment, or pass in True/False to set its value.
Function AllDayAppointment(appt As Outlook.AppointmentItem, Optional isAllDay As Variant) As Boolean
If Not IsMissing(isAllDay) Then
appt.AllDayEvent = isAllDay
End If
AllDayAppointment = appt.AllDayEvent
End Function
Application Property
Function GetApptApplication(appt As Outlook.AppointmentItem) As Outlook.Application Set GetApptApplication = appt.Application End Function
Attachments Property
Function GetAppointmentAttachments(appt As Outlook.AppointmentItem) As Outlook.Attachments Set GetAppointmentAttachments = appt.Attachments End Function
AutoResolvedWinner Property
Function AppointmentAutoResolvedWinner(appt As Outlook.AppointmentItem) As Boolean AppointmentAutoResolvedWinner = ((appt.Conflicts.Count > 0) And (appt.AutoResolvedWinner)) End Function
Conflicts Property
If an appointment is in conflict with another, either the IsConflict property is True or the Conflicts.Count property is greater than zero.
Function IsAppointmentInConflict(appt As Outlook.AppointmentItem) As Boolean IsAppointmentInConflict = ((appt.Conflicts.Count > 0) Or (appt.IsConflict)) End Function
Function GetAppointmentConflicts(appt As Outlook.AppointmentItem) As Outlook.Conflicts Set GetAppointmentConflicts = appt.Conflicts End Function
BillingInformation Property
Function AppointmentBillingInfo(appt As Outlook.AppointmentItem, Optional billingInfo As String, _
Optional append As Boolean = False) As String
' set or get appt billing information
If Len(billingInfo) > 0 Then
If append Then
' append value to existing
appt.BillingInformation = appt.BillingInformation & billingInfo
Else
' set value
appt.BillingInformation = billingInfo
End If
End If
' return whether updated or replaced or just checking value
AppointmentBillingInfo = appt.BillingInformation
End Function
Body Property
Function AppointmentBody(appt As Outlook.AppointmentItem, Optional bodyText As String, _
Optional append As Boolean = False) As String
' set or get Appointment body text
If Len(bodyText) > 0 Then
' set body text
If append Then
' add to existing body text
appt.Body = appt.Body & bodyText
Else
' replace with new body text
appt.Body = bodyText
End If
End If
' return body, whether updated or replaced or just checking value
AppointmentBody = appt.Body
End Function
BusyStatus Property
Function GetAppointmentBusyStatus(appt As Outlook.AppointmentItem) As OlBusyStatus GetAppointmentBusyStatus = appt.BusyStatus End Function
Categories Property
Function GetAppointmentCategories(appt As Outlook.AppointmentItem) As String GetAppointmentCategories = appt.Categories End Function
Class Property
Function GetAppointmentClass(appt As Outlook.AppointmentItem) As OlObjectClass GetAppointmentClass = appt.Class End Function
Companies Property
Function AppointmentCompanies(appt As Outlook.AppointmentItem, Optional companyInfo As String, _
Optional append As Boolean = False) As String
' set or get Appointment companies string
If Len(companyInfo) > 0 Then
If append Then
' append value to existing
appt.Companies = appt.Companies & companyInfo
Else
' set value
appt.Companies = companyInfo
End If
End If
' return whether updated or replaced or just checking value
AppointmentCompanies = appt.Companies
End Function
ConversationIndex Property
Function GetApptCI(appt As Outlook.AppointmentItem) As String GetApptCI = appt.ConversationIndex End Function
ConversationTopic Property
Function GetApptCT(appt As Outlook.AppointmentItem) As String GetApptCT = appt.ConversationTopic End Function
CreationTime Property
Function GetAppointmentCreationTime(appt As Outlook.AppointmentItem) As Date GetAppointmentCreationTime = appt.CreationTime End Function
DownloadState Property
Function GetAppointmentDownloadState(appt As Outlook.AppointmentItem) As OlDownloadState GetAppointmentDownloadState = appt.DownloadState End Function
Duration Property
Function AppointmentDuration(appt As Outlook.AppointmentItem, Optional apptDuration As Long) As Long
' set or get appointment duration
If apptDuration > 0 Then
appt.Duration = apptDuration
End If
AppointmentDuration = appt.Duration
End Function
End Property
Function AppointmentEnd(appt As Outlook.AppointmentItem, Optional apptEnd As Date) As Date
' set or get appt end
If apptEnd <> #1/1/4501# Then
appt.End = apptEnd
End If
AppointmentEnd = appt.End
End Function
EntryID Property
Function GetAppointmentEntryID(appt As Outlook.AppointmentItem) As String GetAppointmentEntryID = appt.EntryID End Function
FormDescription Property
Function GetAppointmentFormDescription(appt As Outlook.AppointmentItem) As Outlook.FormDescription Set GetAppointmentFormDescription = appt.FormDescription End Function
GetInspector Property
Function GetAppointmentInspector(appt As Outlook.AppointmentItem) As Outlook.Inspector Set GetAppointmentInspector = appt.GetInspector End Function
Importance Property
Function GetAppointmentImportance(appt As Outlook.AppointmentItem) As OlImportance GetAppointmentImportance = appt.Importance End Function
InternetCodepage Property
Function GetAppointmentICP(appt As Outlook.AppointmentItem) As Long GetAppointmentICP = appt.InternetCodepage End Function
IsOnlineMeeting Property
Function AppointmentOnlineMeeting(appt As Outlook.AppointmentItem, Optional isOnlineMtg As Variant) As Boolean
' set or get appt online meeting
If Not IsMissing(isOnlineMtg) Then
appt.IsOnlineMeeting = isOnlineMtg
End If
AppointmentOnlineMeeting = appt.IsOnlineMeeting
End Function
IsRecurring Property
Function IsAppointmentRecurring(appt As Outlook.AppointmentItem) As Boolean IsAppointmentRecurring = appt.IsRecurring End Function
ItemProperties Collection Property
Function GetAppointmentItemProperties(appt As Outlook.AppointmentItem) As Outlook.ItemProperties Set GetAppointmentItemProperties = appt.ItemProperties End Function
LastModificationTime Property
Function GetAppointmentLastModTime(appt As Outlook.AppointmentItem) As Date GetAppointmentLastModTime = appt.LastModificationTime End Function
Links Collection Property
Function GetAppointmentLinks(appt As Outlook.AppointmentItem) As Outlook.Links Set GetAppointmentLinks = appt.Links End Function
Location Property
Function AppointmentLocation(appt As Outlook.AppointmentItem, Optional loc As String) As String
' get or set appt location
If Len(loc) > 0 Then
appt.Location = loc
End If
AppointmentLocation = appt.Location
End Function
MarkForDownload Property
Function AppointmentMarkForDownload(appt As Outlook.AppointmentItem, _
Optional remoteStatus As OlRemoteStatus) As OlRemoteStatus
' set or get remote status
Select Case remoteStatus
' if remoteStatus is specified, set it for the current AppointmentItem
Case olMarkedForCopy, olMarkedForDelete, olMarkedForDownload, _
olRemoteStatusNone, olUnMarked
appt.MarkForDownload = remoteStatus
AppointmentMarkForDownload = remoteStatus
Case Else
' just return current status
AppointmentMarkForDownload = appt.MarkForDownload
End Select
End Function
MeetingStatus Property
Function AppointmentMeetingStatus(appt As Outlook.AppointmentItem, _
Optional mtgStatus As OlMeetingStatus) As OlMeetingStatus
Select Case mtgStatus
Case olMeeting, olMeetingCanceled, olMeetingReceived, olNonMeeting
appt.MeetingStatus = mtgStatus
Case Else
AppointmentMeetingStatus = appt.MeetingStatus
End Select
End Function
MeetingWorkspaceURL Property
Function GetMeetingWorkspaceURL(appt As Outlook.AppointmentItem) As String GetMeetingWorkspaceURL = appt.MeetingWorkspaceURL End Function
MessageClass Property
Function AppointmentMessageClass(appt As Outlook.AppointmentItem, Optional msgClass As String) As String
' set or get Appointment message class
' what are the possible values?
If Len(msgClass) > 0 Then
appt.MessageClass = msgClass
AppointmentMessageClass = msgClass
Else
' return value
AppointmentMessageClass = appt.MessageClass
End If
End Function
Mileage Property
Function AppointmentMileage(appt As Outlook.AppointmentItem, Optional mileageValue As String, _
Optional append As Boolean = False) As String
' set or get Appointment mileage
If Len(mileageValue) > 0 Then
If append Then
appt.Mileage = appt.Mileage & mileageValue
Else
appt.Mileage = mileageValue
End If
End If
' return value, either appended, unchanged or changed
AppointmentMileage = appt.Mileage
End Function
NoAging Property
Function AppointmentNoAging(appt As Outlook.AppointmentItem, Optional ageItem As Variant) As Boolean
' set or get Appointment aging
If Not IsMissing(ageItem) Then
appt.NoAging = ageItem
End If
AppointmentNoAging = appt.NoAging
End Function
OptionalAttendees Property
Function ApptOptionalAttendees(appt As Outlook.AppointmentItem, Optional names As String, _
Optional append As Boolean = False) As String
' set (append) or get appt optional attendees
If Len(names) > 0 Then
If append Then
appt.OptionalAttendees = appt.OptionalAttendees & names
Else
appt.OptionalAttendees = names
End If
End If
ApptOptionalAttendees = appt.OptionalAttendees
End Function
Organizer Property
Function AppointmentOrganizer(appt As Outlook.AppointmentItem) As String AppointmentOrganizer = appt.Organizer End Function
OutlookInternalVersion Property
Function AppointmentInternalVersion(appt As Outlook.AppointmentItem) As Long AppointmentInternalVersion = appt.OutlookInternalVersion End Function
OutlookVersion Property
Function AppointmentOutlookVersion(appt As Outlook.AppointmentItem) As String AppointmentOutlookVersion = appt.OutlookVersion End Function
Parent Property
Function GetAppointmentParent(appt As Outlook.AppointmentItem) As Object Set GetAppointmentParent = appt.Parent End Function
Recipients Property
Function GetAppointmentRecipients(appt As Outlook.AppointmentItem) As Outlook.Recipients Set GetAppointmentRecipients = appt.Recipients End Function
RecurrenceState Property
Function GetApptRecurrenceState(appt As Outlook.AppointmentItem) As OlRecurrenceState GetApptRecurrenceState = appt.RecurrenceState End Function
ReminderMinutesBeforeStart Property
Function ApptReminderMinutesBeforeStart(appt As Outlook.AppointmentItem, Optional minutes As Long) As Long
' get or set ReminderMinutesBeforeStart
If minutes > 0 Then
appt.ReminderMinutesBeforeStart = minutes
End If
ApptReminderMinutesBeforeStart = appt.ReminderMinutesBeforeStart
End Function
ReminderOverrideDefault Property
Function ApptReminderOverrideDefault(appt As Outlook.AppointmentItem, Optional override As Variant) As Boolean
' get or set ReminderOverrideDefault
If Not IsMissing(override) Then
appt.ReminderOverrideDefault = override
End If
ApptReminderOverrideDefault = appt.ReminderOverrideDefault
End Function
ReminderPlaySound Property
Function ApptReminderPlaySound(appt As Outlook.AppointmentItem, Optional playSound As Variant) As Boolean
' get or set ReminderPlaySound
If Not IsMissing(playSound) Then
appt.ReminderPlaySound = playSound
End If
ApptReminderPlaySound = appt.ReminderPlaySound
End Function
ReminderSet Property
Function ApptReminderSet(appt As Outlook.AppointmentItem, Optional setReminder As Variant) As Boolean
' get or set ReminderSet
If Not IsMissing(setReminder) Then
appt.ReminderSet = setReminder
End If
ApptReminderSet = appt.ReminderSet
End Function
ReminderSoundFile Property
Function AppointmentReminderSoundFile(appt As Outlook.AppointmentItem, Optional filePath As String) As String
' get or set reminder sound file path
If Len(filePath) > 0 Then
' make sure filepath is valid
If Len(Dir(filePath)) > 0 Then
' set filepath
appt.ReminderSoundFile = filePath
AppointmentReminderSoundFile = filePath
Else
AppointmentReminderSoundFile = appt.ReminderSoundFile
End If
End If
' return filepath
AppointmentReminderSoundFile = appt.ReminderSoundFile
End Function
ReplyTime Property
Function ApptReplyTime(appt As Outlook.AppointmentItem, timeToReply As Date) As Date
If timeToReply <> #1/1/4501# Then
appt.ReplyTime = timeToReply
End If
ApptReplyTime = appt.ReplyTime
End Function
RequiredAttendees Property
Function ApptRequiredAttendees(appt As Outlook.AppointmentItem, Optional names As String, _
Optional append As Boolean = False) As String
' get or set required attendees
' names must be a semicolon-delimited string
If Len(names) > 0 Then
If append Then
' add the names to existing
appt.RequiredAttendees = appt.RequiredAttendees & names
Else
' replace existing
appt.RequiredAttendees = names
End If
End If
ApptRequiredAttendees = appt.RequiredAttendees
End Function
Resources Property
Function ApptResources(appt As Outlook.AppointmentItem, Optional names As String, _
Optional append As Boolean = False) As String
' Returns a semicolon-delimited String of resource names for the meeting.
' This property contains the display names only. The Recipients collection
' should be used to modify the resource recipients. Resources are added
' as BCC recipients to the collection. Read/write.
Dim recips As Outlook.Recipients
Dim recip As Outlook.recipient
Dim resourceName As Variant
Dim resourceNames() As String
Dim i As Long
If Len(names) > 0 Then
resourceNames = Split(names, ";")
Set recips = appt.Recipients
If append Then
' add the names to existing
For Each resourceName In resourceNames
Set recip = recips.Add(resourceName)
recip.Type = olResource
Next resourceName
Else
' replace existing
' first, delete existing resources
For i = recips.Count To 1 Step -1
If recips.Item(i).Type = olResource Then
recips.Item(i).Delete
End If
Next i
' now add in new ones
For Each resourceName In resourceNames
Set recip = recips.Add(resourceName)
recip.Type = olResource
Next resourceName
End If
End If
ApptResources = appt.Resources
End Function
