访问共享的Outlook日历 [英] Accessing Shared Outlook Calendars

查看:88
本文介绍了访问共享的Outlook日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我是开发中的新手.在工作中,我有一个个人日历,然后有我可以访问的共享日历.我正在尝试编写一个脚本来检索每个共享日历中的约会,但是我当前使用的代码(改编自Greg Thatcher)仅允许我检索我的日历中的约会.任何帮助表示赞赏.下面是我的代码.

* -----------------------

Hi..

I am a newbie in development. At work I have a personal calendar and then there are shared calendars that I have access to. I am trying to write a script that retrieves the appointments in each of these shared calendars, but the code I currently use (adapted from Greg Thatcher) only allows me to retrieve appointments in MY calendar. Any assistance is appreciated. below is the code I have.

*-----------------------

Option Explicit
Private Sub CommandButton1_Click()
    GetListOfAppointmentsUsingPropertyAccessor
    Exit Sub
End Sub

Public Sub GetListOfAppointmentsUsingPropertyAccessor()
    On Error GoTo On_Error
    Dim Session As Outlook.NameSpace
    Dim Report As String
    Dim szNewDate As String
    Dim AppointmentsFolder As Outlook.Folder
    Dim currentItem As Object
    Dim currentAppointment As AppointmentItem
    Set Session = Application.Session
    Set AppointmentsFolder = Session.GetDefaultFolder(olFolderCalendar)
    
    For Each currentItem In AppointmentsFolder.Items
        If (currentItem.Class = olAppointment) Then
            Set currentAppointment = currentItem
          
            Call AddToReportIfNotBlank(Report, "BEGIN", "VCALENDAR")
            Call AddToReportIfNotBlank(Report, "BEGIN", "VEVENT")
            Call AddToReportIfNotBlank(Report, "ATTENDEE;CN=", currentAppointment.RequiredAttendees)
            Call AddToReportIfNotBlank(Report, "CLASS", "PRIVATE")
            Call AddToReportIfNotBlank(Report, "CREATED", DateConv(currentAppointment.CreationTime))  '- '18/02/2011 11:48:02
            Call AddToReportIfNotBlank(Report, "DTEND", DateConv(currentAppointment.EndInEndTimeZone)) '- '0110530T080000Z
            Call AddToReportIfNotBlank(Report, "DTSTART", DateConv(currentAppointment.Start)) '- '20110530T070000Z
            Call AddToReportIfNotBlank(Report, "LAST-MODIFIED", DateConv(currentAppointment.LastModificationTime)) '- '20110530T071826Z
            Call AddToReportIfNotBlank(Report, "LOCATION", currentAppointment.Location)
            Call AddToReportIfNotBlank(Report, "ORGANIZER;CN=", currentAppointment.Organizer)
            Call AddToReportIfNotBlank(Report, "SUMMARY;LANGUAGE=en-us", currentAppointment.ConversationTopic)
            Call AddToReportIfNotBlank(Report, "UID", currentAppointment.EntryID)
            Call AddToReportIfNotBlank(Report, "END", "VEVENT")
            Call AddToReportIfNotBlank(Report, "END", "VCALENDAR")
            Report = Report & "--------------------------------------------------------------------------------------------------------"
            Report = Report & vbCrLf & vbCrLf
        End If
    Next
    Call CreateReportAsEmail("List of Appointments", Report)
Exiting:
        Exit Sub
On_Error:
    MsgBox "error=" & Err.Number & " " & Err.Description
    Resume Exiting
End Sub
Private Function AddToReportIfNotBlank(Report As String, FieldName As String, FieldValue)
    AddToReportIfNotBlank = ""
    If (IsNull(FieldValue) Or FieldValue <> "") Then
        AddToReportIfNotBlank = Trim(FieldName & ":" & FieldValue & vbCrLf)
        Report = Report & AddToReportIfNotBlank
    End If
End Function



* -----------------------

谢谢,
Thembani



*-----------------------

Thanks,
Thembani

推荐答案

您必须使用GetSharedDefaultFolder而不是GetDefaultFolder
首先通过.CreateRecipient
You have to use GetSharedDefaultFolder instead of GetDefaultFolder
First create a Recipient via .CreateRecipient


这篇关于访问共享的Outlook日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆