0

我们必须在程序控制(VB 或 Ruby)下为多个用户添加和更新 Outlook 日历事件(每个用户的不同约会事件)。个人用户不需要任何操作的服务器解决方案是首选。简单的基于 ICAL 的技术似乎不容易支持更新现有事件(即日程更改)。

任何指针(片段、API 文档将不胜感激)

顺便说一句:我们目前拥有一个非基于服务器的解决方案,其中每个用户都必须运行类似于以下的脚本:

# Loosely based on http://snippets.dzone.com/posts/show/4301

require 'delegate_to'
require 'win32ole'

# Simple DSL wrapper out Outlook API
class OutlookCalendar < Array
    CALENDAR_FOLDER=9
    OUTLOOK=WIN32OLE.new 'Outlook.Application'

    class Event
        def initialize &block
            @_=OutlookCalendar::OUTLOOK.CreateItem 1
            instance_eval(&block) if block_given?
        end
        def subject *arg
            @_.subject=arg.first unless arg.empty?
            @_.Subject
        end
        def start *arg
            @_.Start=arg.first unless arg.empty?
            @_.Start
        end
        def duration *arg
            @_.Duration=arg.first unless arg.empty?
            @_.Duration
        end
        def body *arg
            @_.Body=arg.first unless arg.empty?
            @_.Body
        end
        def location *arg
            @_.Location=arg.first unless arg.empty?
            @_.location
        end
        def reminder *arg
            @_.ReminderMinutesBeforeStart=arg.first unless arg.empty?
            @_.ReminderSet=true
            @_.ReminderMinutesBeforeStart
        end

        delegate_to :_
    end


    def initialize
        super
        refresh
        each{|_| yield _} if block_given?
    end

    def refresh
        mapi=OutlookCalendar::OUTLOOK.GetNameSpace 'MAPI'
        @calendar=mapi.GetDefaultFolder CALENDAR_FOLDER
        entries=[] #  [ Subject Location Start End Body ]
        @calendar.Items.each{|_| entries << _} # can't use collect
        self.replace entries.sort_by{|_| _.Start}
        self
    end

    def << event
        event.save
    end
end

# Sample Usage:
if $0==__FILE__

    class OutlookCalendar
        def show
            each{|_| puts '%s - %s : %s' % [ _.Start,_.End,_.Subject ]}
        end
    end

    Calendar=OutlookCalendar.new

    # Show original events
    Calendar.show

    # Delete possible previous events       
    Calendar.each{|_| _.Delete if /^S3W:/.match _.Subject}

    # Add updated event
    Calendar << OutlookCalendar::Event.new do
        start '7/29/2007 11:00 AM'
        duration 300
        subject 'S3W: Hall of Fame Induction'
        body 'Tony Gwynn and Cal Ripken Jr.'
        location 'Cooperstown, NY'
        reminder 15
    end

    # Show updated list of events
    puts '-'*50
    Calendar.refresh.show

end    
4

1 回答 1

0

Outlook、Exchange 和 WebDav。

  • 如何在 Visual C# 中使用 WebDAV 创建 Outlook 日历文件夹
  • 如何在 Visual Basic .NET 中使用 WebDAV 来处理 Exchange 2000 中的项目
于 2009-09-10T14:10:07.503 回答