CalendarSharing-Objekt (Outlook)CalendarSharing object (Outlook)

Stellt einen Satz Dienstprogramme für das Freigeben von Kalenderinformationen dar.Represents a set of utilities for sharing calendar information.

BemerkungenRemarks

Sie können die GetCalendarExporter -Methode eines Folder -Objekts verwenden, das einen Kalenderordner darstellt, um ein CalendarSharing -Objekt zu erstellen.You can use the GetCalendarExporter method of a Folder object that represents a calendar folder to create a CalendarSharing object. GetCalendarExporter -Methode kann nur für Kalenderordner verwendet werden.The GetCalendarExporter method can only be used on calendar folders. Ein Fehler tritt auf, wenn Sie die Methode für Folder -Objekten verwenden, die andere Ordnertypen darstellen.An error occurs if you use the method on Folder objects that represent other folder types.

Sie können die SaveAsICal -Methode verwenden, um Kalenderinformationen in einer iCalendar-Datei (ICS) zu speichern, um einen Kalender als URL freizugeben, oder verwenden Sie die ForwardAsICal -Methode, um ein MailItem für die Freigabe eines Kalenders als Nutzlast zu erstellen. You can use the SaveAsICal method to save calendar information in an iCalendar (.ics) file for sharing a calendar as a URL, or use the ForwardAsICal method to create a MailItem for sharing a calendar as a payload.

Hinweis

Das CalendarSharing-Objekt unterstützt nur das Exportieren des iCalendar-Dateiformats.The CalendarSharing object only supports exporting the iCalendar format.

BeispielExample

Im folgenden Beispiel für Visual Basic für Applikationen (VBA) wird ein CalendarSharing -Objekt für den Ordner Kalender erstellt, und anschließend wird der Inhalt des gesamten Ordners (einschließlich Anlagen und privater Elemente) in eine iCalendar-Kalenderdatei (ICS) exportiert.The following Visual Basic for Applications (VBA) example creates a CalendarSharing object for the Calendar folder, then exports the contents of the entire folder (including attachments and private items) to an iCalendar calendar (.ics) file.

Public Sub ExportEntireCalendar() 
 
 
 
 Dim oNamespace As NameSpace 
 
 Dim oFolder As Folder 
 
 Dim oCalendarSharing As CalendarSharing 
 
 
 
 On Error GoTo ErrRoutine 
 
 
 
 ' Get a reference to the Calendar default folder 
 
 Set oNamespace = Application.GetNamespace("MAPI") 
 
 Set oFolder = oNamespace.GetDefaultFolder(olFolderCalendar) 
 
 
 
 ' Get a CalendarSharing object for the Calendar default folder. 
 
 Set oCalendarSharing = oFolder.GetCalendarExporter 
 
 
 
 ' Set the CalendarSharing object to export the contents of 
 
 ' the entire Calendar folder, including attachments and 
 
 ' private items, in full detail. 
 
 With oCalendarSharing 
 
 .CalendarDetail = olFullDetails 
 
 .IncludeAttachments = True 
 
 .IncludePrivateDetails = True 
 
 .IncludeWholeCalendar = True 
 
 End With 
 
 
 
 ' Export calendar to an iCalendar calendar (.ics) file. 
 
 oCalendarSharing.SaveAsICal "C:\SampleCalendar.ics" 
 
 
 
EndRoutine: 
 
 On Error GoTo 0 
 
 Set oCalendarSharing = Nothing 
 
 Set oFolder = Nothing 
 
 Set oNamespace = Nothing 
 
Exit Sub 
 
 
 
ErrRoutine: 
 
 Select Case Err.Number 
 
 Case 287 ' &H0000011F 
 
 ' The user denied access to the Address Book. 
 
 ' This error occurs if the code is run by an 
 
 ' untrusted application, and the user chose not to 
 
 ' allow access. 
 
 MsgBox "Access to Outlook was denied by the user.", _ 
 
 vbOKOnly, _ 
 
 Err.Number & " - " & Err.Source 
 
 Case -2147467259 ' &H80004005 
 
 ' Export failed. 
 
 ' This error typically occurs if the CalendarSharing 
 
 ' method cannot export the calendar information because 
 
 ' of conflicting property settings. 
 
 MsgBox Err.Description, _ 
 
 vbOKOnly, _ 
 
 Err.Number & " - " & Err.Source 
 
 Case -2147221233 ' &H8004010F 
 
 ' Operation failed. 
 
 ' This error typically occurs if the GetCalendarExporter method 
 
 ' is called on a folder that doesn't contain calendar items. 
 
 MsgBox Err.Description, _ 
 
 vbOKOnly, _ 
 
 Err.Number & " - " & Err.Source 
 
 Case Else 
 
 ' Any other error that may occur. 
 
 MsgBox Err.Description, _ 
 
 vbOKOnly, _ 
 
 Err.Number & " - " & Err.Source 
 
 End Select 
 
 
 
 GoTo EndRoutine 
 
End Sub

MethodenMethods

NameName
ForwardAsICalForwardAsICal
SaveAsICalSaveAsICal

EigenschaftenProperties

NameName
ApplicationApplication
CalendarDetailCalendarDetail
KlasseClass
EndDateEndDate
OrdnerFolder
IncludeAttachmentsIncludeAttachments
IncludePrivateDetailsIncludePrivateDetails
IncludeWholeCalendarIncludeWholeCalendar
ParentParent
RestrictToWorkingHoursRestrictToWorkingHours
SessionSession
StartDateStartDate

Siehe auchSee also

Outlook-ObjektmodellreferenzOutlook Object Model Reference

Support und FeedbackSupport and feedback

Haben Sie Fragen oder Feedback zu Office VBA oder zu dieser Dokumentation?Have questions or feedback about Office VBA or this documentation? Unter Office VBA-Support und Feedback finden Sie Hilfestellung zu den Möglichkeiten, wie Sie Support erhalten und Feedback abgeben können.Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.