共用方式為


Outlook) (AppointmentItem 物件

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

註解

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

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

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

當您使用週期性約會專案時,您應該釋放任何先前的參考、在存取或修改專案之前取得週期性約會專案的新參考,並在完成並儲存變更後立即釋放這些參考。 此作法適用于週期性 AppointmentItem 物件,以及任何 ExceptionRecurrencePattern 物件。 若要在 Visual Basic for Applications (VBA) 或 Visual Basic 中釋放參考,請將該現有物件設定為 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 支援與意見反應