Objet AppointmentItem (Outlook)

Représente une réunion, un rendez-vous ponctuel ou périodique, ou une réunion dans le dossier Calendrier.

Remarques

Utilisez la méthode CreateItem pour créer un objet AppointmentItem qui représente un nouveau rendez-vous.

Utilisez Items (index), où index est le numéro d’index d’un rendez-vous ou une valeur utilisée pour correspondre à la propriété par défaut d’un rendez-vous, pour renvoyer un seul objet AppointmentItem à partir d’un dossier Calendar.

Vous pouvez également renvoyer un objet AppointmentItem à partir d’un objet MeetingItem à l’aide de la méthode GetAssociatedAppointment .

Lors de l'utilisation d'éléments de rendez-vous périodique, vous devez libérer les références antérieures, le cas échéant, obtenir les nouvelles références à l'élément de rendez-vous périodique avant d'accéder à cet élément ou de le modifier, et libérer ces références dès que vous avez terminé et enregistré les modifications. Cette pratique s’applique à l’objet AppointmentItem récurrent et à tout objet Exception ou RecurrencePattern . Pour libérer une référence dans Visual Basic pour Applications (VBA) ou Visual Basic, définissez cet objet existant sur Nothing. Dans C#, libérez explicitement la mémoire pour cet objet.

Notez que même après avoir libéré votre référence et tenté d’obtenir une nouvelle référence, s’il existe encore une référence active détenue par un autre complément ou par Outlook vers un des objets mentionnés ci-dessus, votre nouvelle référence pointera encore vers une copie périmée de l’objet. Il est donc important de libérer vos références dès que vous en avez terminé avec le rendez-vous périodique.

L'exemple de code suivant dans VBA montre comment libérer et actualiser des références afin d'obtenir des données à jour pour un rendez-vous périodique. L'exemple obtient un ensemble d'éléments de rendez-vous du dossier Calendrier. Il suppose que le premier élément dans la collection de rendez-vous fait partie d'un rendez-vous périodique. L'exemple montre qu'une référence à la collection de rendez-vous obtenue avant la création d'une exception ne reflète pas cette dernière. L'exemple libère ensuite cette référence et d'autres références de rendez-vous existantes, après quoi les nouvelles références pointant sur la collection de rendez-vous reflètent l'exception.

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

Exemple

L'exemple Visual Basic pour Applications (VBA) suivant renvoie un nouveau rendez-vous.

Set myItem = Application.CreateItem(olAppointmentItem)

Événements

Nom
AfterWrite
AttachmentAdd
AttachmentRead
AttachmentRemove
BeforeAttachmentAdd
BeforeAttachmentPreview
BeforeAttachmentRead
BeforeAttachmentSave
BeforeAttachmentWriteToTempFile
BeforeAutoSave
BeforeCheckNames
BeforeDelete
BeforeRead
Close
CustomAction
CustomPropertyChange
Transférer
Open
PropertyChange
Lire
ReadComplete
Reply
ReplyAll
Send
Unload
Write

Méthodes

Nom
ClearRecurrencePattern
Close
Copy
CopyTo
Supprimer
Display
ForwardAsVcal
GetConversation
GetOrganizer
GetRecurrencePattern
Move
PrintOut
Respond
Save
SaveAs
Send
ShowCategoriesDialog

Propriétés

Nom
Actions
AllDayEvent
Application
Pièces jointes
AutoResolvedWinner
BillingInformation
Body
BusyStatus
Categories
Classe
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

Voir aussi

Référence du modèle d'objet OutlookImportation de données XML de rendez-vous dans des objets de rendez-vous OutlookMembres de l'objet AppointmentItem

Assistance et commentaires

Avez-vous des questions ou des commentaires sur Office VBA ou sur cette documentation ? Consultez la rubrique concernant l’assistance pour Office VBA et l’envoi de commentaires afin d’obtenir des instructions pour recevoir une assistance et envoyer vos commentaires.