Outlook) (AppointmentItem 物件

代表 [行事曆] 資料夾中的會議、一次約會或週期性約會。

註解

使用 CreateItem 方法建立代表新約會的 AppointmentItem 物件。

使用 [項目] (索引) ,其中 index 是約會的索引號碼,或是用來比對約會預設屬性的值,以從 Calendar 資料夾傳回單一 AppointmentItem 物件。

您也可以使用 GetAssociatedAppointment 方法,從 MeetingItem 物件傳回 AppointmentItem 物件。

當您使用週期性約會項目時,應釋出任何先前的參照,在存取或修改項目之前取得週期性約會項目的新參照,並在完成並儲存變更後立即釋出這些參照。 此作法適用於週期性 AppointmentItem 物件,以及任何 Exception 或 RecurrencePattern 物件。 若要在 VBA) 或 Visual Basic (Visual Basic for Applications 中釋放參照,請將該現有物件設定 為 Nothing。 在 C# 中明確釋放該物件的記憶體。

請注意,即使在您釋放參照並嘗試取得新的參照之後,如果其他增益集或 Outlook 對上述其中一個物件仍有作用中的參照,您的新參照仍會指向該物件的過期複本。 因此,在完成定期預約後立即發布推薦信非常重要。

下列 VBA 程式碼範例示範如何釋放和重新整理參照,以便取得週期性約會的最新資料。 此範例會從 Calendar 資料夾取得一組約會項目。 它假設約會集合中的第一個項目是週期性約會的一部分。 這個範例顯示,在建立例外狀況之前取得的約會集合參考不會反映例外狀況。 然後,範例會釋放此參照和其他現有的約會參照,之後指向約會集合的新參照會反映例外狀況。

Sub TestExceptions() 
 
 Dim oItems As Items 
 
 Dim oItemOriginal As AppointmentItem 
 
 Dim oItemNew As AppointmentItem 
 
 Dim rPattern As RecurrencePattern 
 
 Dim oEx As Exceptions 
 
 Dim oEx2 As Exceptions 
 
 Dim oOccurrence As AppointmentItem 
 
 Dim i As Long 
 
 
 
 ' This is the initial reference to an appointment collection. 
 
 Set oItems = _ 
 
 Outlook.Application.Session.GetDefaultFolder(olFolderCalendar).Items 
 
 
 
 ' This is the original reference to the first appointment in the 
 
 ' collection before an exception is created. 
 
 Set oItemOriginal = oItems.Item(1) 
 
 
 
 ' Code example assumes that the first appointment in the collection 
 
 ' is a recurring appointment. 
 
 Set oOccurrence = _ 
 
 oItemOriginal.GetRecurrencePattern().GetOccurrence(#2/28/2010 8:00:00 AM#) 
 
 
 
 ' Create an exception by changing the 2/28 occurrence to 3/3. 
 
 oOccurrence.Start = #3/3/2010 8:00:00 AM# 
 
 oOccurrence.Save 
 
 
 
 Stop 
 
 
 
 ' Preexisting reference to the first appointment in the collection 
 
 ' does not reflect the exception. 
 
 oItemOriginal.Save 
 
 Set oEx = oItemOriginal.GetRecurrencePattern().Exceptions 
 
 Debug.Print oItemOriginal.subject 
 
 Debug.Print " Original item exceptions: " & oEx.Count 
 
 
 
 ' Get a new reference based on the existing reference to the 
 
 ' appointment collection created before the exception. 
 
 ' The new reference does not reflect the exception. 
 
 Set oItemNew = oItems.Item(1) 
 
 oItemNew.Save 
 
 Set oEx2 = oItemNew.GetRecurrencePattern().Exceptions 
 
 Debug.Print " New item exceptions: " & oEx2.Count 
 
 
 
 ' Same: preexisting reference to the first appointment in the collection 
 
 ' does not reflect the exception. 
 
 Set oEx = oItemOriginal.GetRecurrencePattern().Exceptions 
 
 Debug.Print " Original item exceptions: " & oEx.Count 
 
 
 
 ' Release all existing references to appointment items, 
 
 ' including the appointment collection, an exception, occurrence, 
 
 ' or any other appointment. 
 
 Debug.Print "REFRESH ITEM COLLECTION" 
 
 Set oItems = Nothing 
 
 Set oItemNew = Nothing 
 
 Set oEx = Nothing 
 
 Set oEx2 = Nothing 
 
 Set oOccurrence = Nothing 
 
 Set oItemOriginal = Nothing 
 
 Set rPattern = Nothing 
 
 
 
 ' Get new references to appointment items, including the appointment 
 
 ' collection, individual appointments, and exceptions. 
 
 Set oItems = _ 
 
 Outlook.Application.Session.GetDefaultFolder(olFolderCalendar).Items 
 
 Set oItemNew = oItems.Item(1) 
 
 
 
 ' If no other add-ins have the same recurring appointment open, 
 
 ' the new references reflect the current exception count. 
 
 Set oEx2 = oItemNew.GetRecurrencePattern().Exceptions 
 
 Debug.Print " New item exceptions: " & oEx2.Count 
 
 
 
 Debug.Print "RE-GET ORIGINAL" 
 
 Set oItemOriginal = oItems.Item(1) 
 
 Set oEx = oItemOriginal.GetRecurrencePattern().Exceptions 
 
 Debug.Print " Original item exceptions: " & oEx.Count 
 
End Sub

範例

以下 Visual Basic for Applications (VBA) 範例傳回新約會。

Set myItem = Application.CreateItem(olAppointmentItem)

事件

名稱
AfterWrite
AttachmentAdd
AttachmentRead
AttachmentRemove
BeforeAttachmentAdd
BeforeAttachmentPreview
BeforeAttachmentRead
BeforeAttachmentSave
BeforeAttachmentWriteToTempFile
BeforeAutoSave
BeforeCheckNames
BeforeDelete
BeforeRead
Close
CustomAction
CustomPropertyChange
Forward
Open
PropertyChange
Read
ReadComplete
Reply
ReplyAll
Send
Unload
Write

方法

名稱
ClearRecurrencePattern
Close
Copy
CopyTo
Delete
Display
ForwardAsVcal
GetConversation
GetOrganizer
GetRecurrencePattern
Move
PrintOut
Respond
Save
SaveAs
Send
ShowCategoriesDialog

屬性

名稱
Actions
AllDayEvent
Application
Attachments
AutoResolvedWinner
BillingInformation
Body
BusyStatus
Categories
Class
Companies
Conflicts
ConversationID
ConversationIndex
ConversationTopic
CreationTime
DownloadState
Duration
End
EndInEndTimeZone
EndTimeZone
EndUTC
EntryID
ForceUpdateToAllAttendees
FormDescription
GetInspector
GlobalAppointmentID
Importance
InternetCodepage
IsConflict
IsRecurring
ItemProperties
LastModificationTime
Location
MarkForDownload
MeetingStatus
MeetingWorkspaceURL
MessageClass
Mileage
NoAging
OptionalAttendees
Organizer
OutlookInternalVersion
OutlookVersion
Parent
PropertyAccessor
Recipients
RecurrenceState
ReminderMinutesBeforeStart
ReminderOverrideDefault
ReminderPlaySound
ReminderSet
ReminderSoundFile
ReplyTime
RequiredAttendees
Resources
ResponseRequested
ResponseStatus
RTFBody
Saved
SendUsingAccount
Sensitivity
Session
Size
Start
StartInStartTimeZone
StartTimeZone
StartUTC
Subject
UnRead
UserProperties

另請參閱

Outlook 物件模型參考如何:將約會 XML 資料匯入 Outlook 約會物件AppointmentItem 物件成員

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。