Outlook 自动化从 Web 应用程序创建约会

发布于 2024-08-08 18:18:30 字数 161 浏览 7 评论 0原文

使用 ActiveX 技术从 Web 应用程序实现 Outlook 自动化是标准做法吗?这与从 Web 应用程序本身安排约会的 Web 调度程序(如 Telerik 的 RadScheduler + Telerik 的 Exchange Provider)相比如何?

谢谢,
森德希尔

Is it a standard practice to automate outlook from a web application using ActiveX technology? How does this compare with a web scheduler like telerik's RadScheduler + telerik's Exchange Provider to schedule an appointment from the web application itself?

Thanks,
Sendhil

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

依 靠 2024-08-15 18:18:30

您将需要提供有关您想要完成的任务的更多详细信息,而不仅仅是说明 Web 应用程序中 Outlook 的自动化。我之所以这么说是因为这实际上取决于您想要做什么。如果您想做的只是创建一个约会,那么您不需要 activex。

您可以研究或研究以下内容。立即进入 Outlook,创建约会。然后转到文件菜单并执行“另存为”并将约会保存到桌面上。您会注意到该文件存储为 .ics 文件。您实际上可以在记事本或word中打开该文件并查看其内容。

例如,下面是记事本中的示例:

BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
CLASS:PUBLIC
CREATED:20091028T125325Z
DESCRIPTION:test\n
DTEND:20091028T133000Z
DTSTAMP:20091028T125325Z
DTSTART:20091028T130000Z
LAST-MODIFIED:20091028T125325Z
PRIORITY:5
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:test
TRANSP:OPAQUE
UID:040000008200E00074C5B7101A82E008000000005062431CAC57CA01000000000000000
    0100000003E756880D89B504BBA9FF0FDC7D16F43
X-ALT-DESC;FMTTYPE=text/html:\n\n\n\n\n\n\n\n\ntest

\n\n\n X-MICROSOFT-CDO-BUSYSTATUS:BUSY X-MICROSOFT-CDO-IMPORTANCE:1 X-MICROSOFT-DISALLOW-COUNTER:FALSE X-MS-OLK-ALLOWEXTERNCHECK:TRUE X-MS-OLK-CONFTYPE:0 BEGIN:VALARM TRIGGER:-PT15M ACTION:DISPLAY DESCRIPTION:Reminder END:VALARM END:VEVENT END:VCALENDAR

现在想想,您可以使用 asp.net/asp 生成约会,因为您可以访问 StreamWriter 和内存流。这到底是什么意思,这意味着您可以生成一个像这样的文本文件,猜猜如果您生成这样的文本文件然后您刚刚创建了一个约会会怎么样。这是我为日历项目编写的示例,我编写了一个工具来跟踪我工作的公司的假期/休假请求。经理想要的功能之一是将员工请求添加到经理日历中。由于经理总是在 Outlook 中,他们希望快速浏览一下 Outlook 日历,看看谁在办公室,谁不在办公室。当然,他们可以手动创建 Outlook 日历项目,但过多的手动工作并不理想。

因此,我使用 StreamWriter 和内存流来生成 Outlook 日历项目。

这是一个例子:

<%@ Page Language="vb" ContentType="text/html" ResponseEncoding="iso-8859-1" Debug="True" trace="False"%>
<%@ import Namespace="System.IO" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title></head>
<body>
<script runat="server"> 
Sub Page_Load(Sender As Object, E As EventArgs) 

 'PARAMETERS
    Dim beginDate as Date
    Dim endDate as Date  

    Dim VType as String = Request.QueryString("vtype")
        Dim h As Double = Request.QueryString("hours")

        If h = 8 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 4:00 PM"
        ElseIf h = 4 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 12:00 PM"
        ElseIf h = 1 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 8:00 AM"
        ElseIf h = 2 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 9:00 AM"
        ElseIf h = 3 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 10:00 AM"
        ElseIf h = 5 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 12:00 PM"
        ElseIf h = 6 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 1:00 PM"
        ElseIf h = 7 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 2:00 PM"
        ElseIf h = 9 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 5:00 PM"
        ElseIf h = 10 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 6:00 PM"
        ElseIf h = 11 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 7:00 PM"
        ElseIf h = 12 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 8:00 PM"
        ElseIf h = 13 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 9:00 PM"
        ElseIf h = 14 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 10:00 PM"
        Else
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 12:00 AM"
        End If

    Dim myLocation as String = Request.QueryString("location")
    Dim mySubject as String = Request.QueryString("subject")
    Dim myDescription as String = Request.QueryString("Description") 

    'INITIALIZATION
    Dim mStream As new MemoryStream()
    Dim writer As new StreamWriter(mStream)

    writer.AutoFlush = true 

    'HEADER
    writer.WriteLine("BEGIN:VCALENDAR")
    writer.WriteLine("PRODID:-//Flo Inc.//FloSoft//EN")
    writer.WriteLine("BEGIN:VEVENT") 

    'BODY
    writer.WriteLine("DTSTART:" & beginDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z") )
    writer.WriteLine("DTEND:" & endDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z") )
    writer.WriteLine("LOCATION:" & myLocation)
    writer.WriteLine("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" & myDescription)
        writer.WriteLine("SUMMARY:" & mySubject)
        writer.WriteLine("X-MICROSOFT-CDO-BUSYSTATUS:FREE")

    'FOOTER
    writer.WriteLine("PRIORITY:5")
    writer.WriteLine("END:VEVENT")
    writer.WriteLine("END:VCALENDAR") 

    'MAKE IT DOWNLOADABLE
    Response.Clear() 'clears the current output content from the buffer
    Response.AppendHeader("Content-Disposition", "attachment; filename=Add2Calendar.vcs")
    Response.AppendHeader("Content-Length", mStream.Length.ToString())
    Response.ContentType = "application/download"
    Response.BinaryWrite(mStream.ToArray())
    Response.End() 
    End Sub
</script>
</body>
</html>

You will need to provide more details about what you are trying to accomplish rather then just stating automation of outlook within a web application. The reason I say this is because it really depends on what you are trying to do. If all you are trying to do is create an appointment then no you do not need activex.

Here is something you can research or look into. Go into outlook right now, create an appointment. Then go to the file menu and do a "Save As" and save the appointment onto your desktop. You will notice the file is stored as a .ics file. You can actually open this file in notepad or word and view the contents of it.

For example here is a sample of what it looks like in notepad:

BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
CLASS:PUBLIC
CREATED:20091028T125325Z
DESCRIPTION:test\n
DTEND:20091028T133000Z
DTSTAMP:20091028T125325Z
DTSTART:20091028T130000Z
LAST-MODIFIED:20091028T125325Z
PRIORITY:5
SEQUENCE:0
SUMMARY;LANGUAGE=en-us:test
TRANSP:OPAQUE
UID:040000008200E00074C5B7101A82E008000000005062431CAC57CA01000000000000000
    0100000003E756880D89B504BBA9FF0FDC7D16F43
X-ALT-DESC;FMTTYPE=text/html:\n\n\n\n\n\n\n\n\ntest

\n\n\n X-MICROSOFT-CDO-BUSYSTATUS:BUSY X-MICROSOFT-CDO-IMPORTANCE:1 X-MICROSOFT-DISALLOW-COUNTER:FALSE X-MS-OLK-ALLOWEXTERNCHECK:TRUE X-MS-OLK-CONFTYPE:0 BEGIN:VALARM TRIGGER:-PT15M ACTION:DISPLAY DESCRIPTION:Reminder END:VALARM END:VEVENT END:VCALENDAR

So now think about this, you can use asp.net / asp to generate an appointment because you have access to a StreamWriter and a memory stream. What exactly does this mean, it means you can generate a text file just like this and guess what if you generate a text file like this then you just created an appointment. Here is an example I wrote for a calendar item, I had written a tool to track vacation / time off requests for a company I work at. One of the features managers wanted was a way to add the employee request to the managers calendar. Due to managers always being inside of outlook they wanted to quickly glance at their outlook calendar and see who was in the office and who wasn't. Sure they could manually create the outlook calendar item but too much manual work was not ideal.

So I used a StreamWriter and a memory stream to generate an outlook calendar item.

Here is an example:

<%@ Page Language="vb" ContentType="text/html" ResponseEncoding="iso-8859-1" Debug="True" trace="False"%>
<%@ import Namespace="System.IO" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title></head>
<body>
<script runat="server"> 
Sub Page_Load(Sender As Object, E As EventArgs) 

 'PARAMETERS
    Dim beginDate as Date
    Dim endDate as Date  

    Dim VType as String = Request.QueryString("vtype")
        Dim h As Double = Request.QueryString("hours")

        If h = 8 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 4:00 PM"
        ElseIf h = 4 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 12:00 PM"
        ElseIf h = 1 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 8:00 AM"
        ElseIf h = 2 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 9:00 AM"
        ElseIf h = 3 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 10:00 AM"
        ElseIf h = 5 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 12:00 PM"
        ElseIf h = 6 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 1:00 PM"
        ElseIf h = 7 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 2:00 PM"
        ElseIf h = 9 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 5:00 PM"
        ElseIf h = 10 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 6:00 PM"
        ElseIf h = 11 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 7:00 PM"
        ElseIf h = 12 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 8:00 PM"
        ElseIf h = 13 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 9:00 PM"
        ElseIf h = 14 Then
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 10:00 PM"
        Else
            beginDate = Request.QueryString("vdate") & " 7:00 AM"
            endDate = Request.QueryString("vdate") & " 12:00 AM"
        End If

    Dim myLocation as String = Request.QueryString("location")
    Dim mySubject as String = Request.QueryString("subject")
    Dim myDescription as String = Request.QueryString("Description") 

    'INITIALIZATION
    Dim mStream As new MemoryStream()
    Dim writer As new StreamWriter(mStream)

    writer.AutoFlush = true 

    'HEADER
    writer.WriteLine("BEGIN:VCALENDAR")
    writer.WriteLine("PRODID:-//Flo Inc.//FloSoft//EN")
    writer.WriteLine("BEGIN:VEVENT") 

    'BODY
    writer.WriteLine("DTSTART:" & beginDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z") )
    writer.WriteLine("DTEND:" & endDate.ToUniversalTime.ToString("yyyyMMdd\THHmmss\Z") )
    writer.WriteLine("LOCATION:" & myLocation)
    writer.WriteLine("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" & myDescription)
        writer.WriteLine("SUMMARY:" & mySubject)
        writer.WriteLine("X-MICROSOFT-CDO-BUSYSTATUS:FREE")

    'FOOTER
    writer.WriteLine("PRIORITY:5")
    writer.WriteLine("END:VEVENT")
    writer.WriteLine("END:VCALENDAR") 

    'MAKE IT DOWNLOADABLE
    Response.Clear() 'clears the current output content from the buffer
    Response.AppendHeader("Content-Disposition", "attachment; filename=Add2Calendar.vcs")
    Response.AppendHeader("Content-Length", mStream.Length.ToString())
    Response.ContentType = "application/download"
    Response.BinaryWrite(mStream.ToArray())
    Response.End() 
    End Sub
</script>
</body>
</html>
诗笺 2024-08-15 18:18:30

您可以通过多种方法从 ASP.NET 应用程序实现 MS Office 自动化,但您需要自行承担风险。如果我没记错的话,您很可能需要使用模拟才能使 dcom 正常运行,这样做可能会在您的 Web 应用程序中留下一个大的安全漏洞。

我建议使用 Open Office XML 因为 MS 不推荐也不支持从 Web 应用程序中自动化 Office。

There are ways that you can automate MS office from an asp.net application but such you do so at your own risk. If I remember correctly, you will more than likely need to use impersonation in order for dcom to function correctly and in doing so you will possibly leave a large security hole in your web application.

I would suggest using Open Office XML as MS does not recommend nor support automating Office from within a web application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文