Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将EWS代码转换为coldfusion_C#_Coldfusion_Exchange Server_Exchangewebservices - Fatal编程技术网

C# 将EWS代码转换为coldfusion

C# 将EWS代码转换为coldfusion,c#,coldfusion,exchange-server,exchangewebservices,C#,Coldfusion,Exchange Server,Exchangewebservices,我不确定“使用”是什么语言,但Coldfusion的等价物是什么 using Microsoft.Exchange.WebServices.Data; Appointment appointment = new Appointment(service); appointment.Subject = subject; appointment.Start = DateTime.Parse(StartDate); appointment.End = DateTime.Parse(EndDate); a

我不确定“使用”是什么语言,但Coldfusion的等价物是什么

using Microsoft.Exchange.WebServices.Data;
Appointment appointment = new Appointment(service);
appointment.Subject = subject;
appointment.Start = DateTime.Parse(StartDate);
appointment.End = DateTime.Parse(EndDate);
appointment.IsReminderSet = false;
appointment.Save();

我遇到这个问题是因为我需要解决EWS API的凭证问题。我包括了我的Coldfusion代码解决方案。我使用了CF 9.1和CF 10

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
    <head>
        <title>EWS test</title>
    </head>

    <body>
        <cfoutput>
            <!--- Init the credentials and serversettings for testing--->
            <!---
                The username can be any of the following formats depending on the AD settings
                ewstest
                ewstest@myDomain
                ewstest\ADdomain
        --->
        <cfset myUsername   = "ewstest" >
        <cfset myPassword   = "*******" >
        <!---
            The ADdomain must mach. It might not be the same as the e-mail domainname.
        --->
        <cfset myDomain     = "ADdomain" >
        <cfset myServer     = "owaserver" >

        <cfset theRecipient = "test@test.com">

    </cfoutput>
    <cfoutput>
    <!--- 
                Author  : Lion van Koppenhagen
                Version : 1.5
                Notes       : This sollution is shared by me at adobe.com at 2011-08-22
                                    To allow developers to work with this sollution, Adobe included the needed libraries in Coldfusion 10.0 and up.

                Description
                ===========
            With Exchange 2007 Microsoft abandoned WebDav as an interface to Exchangeserver.
            The standard Coldfusion Tags relied on WebDav and will not work anymore.

            Since I needed a way to interface with Exchange Server I started looking for possible solutions and this is what I came up with.

            In december 2010 Microsoft released the Exchange Managed Services Library for java.
            You can find it here: http://archive.msdn.microsoft.com/ewsjavaapi/Release/ProjectReleases.aspx?ReleaseId=5691

            In the getting started document it tells you it depends on 4 3rd party libraries which you need to be download separately:
                -    Apache Commons HttpClient 3.1 (commons-httpclient-3.1.jar)
                -    Apache Commons Codec 1.4 (commons-codec-1.4.jar)
                -    Apache Commons Logging 1.1.1 (commons-codec-1.4.jar)
                -    JCIFS 1.3.15 (jcifs-1.3.15.jar)

            With Coldfusion 9.1 (the version I tested with) you only need
                -    JCIFS 1.3.15 (jcifs-1.3.15.jar) which you can download here: http://jcifs.samba.org/src/

            Place the EWS Jar and the JCIFS Jar in your Coldfusion libray folder and after restarting CF server the following code should work.                         

                With Coldfusion 10.0 the JCIFS jar and EWS jar are standard installed in the lib directory.

                Additional notes
                ================
                2015-05-01
                While testing this sollution against a new customer a ran into a 401 access denied error.
                After debugging with our client we found out the domain used to verify the credentials must match the internal AD domain.
        --->
        <!--- 1. I need an instance of the ExchangeService class --->
        <cfobject type="Java" class="microsoft.exchange.webservices.data.ExchangeService" name="service">
        <cfset service.init()>

        <!--- 2.  I need to set the credentials --->
        <!--- 2a. Create an instance of the WebCredentials class --->
        <cfobject type="Java" class="microsoft.exchange.webservices.data.WebCredentials" name="credentials">
        <!--- 2b. Set the credentials --->
        <cfset credentials.init("#myUsername#","#myPassword#", "#myDomain")>
        <!--- 2c. Set the credentials in the service object --->
        <cfset service.setCredentials(credentials) />

        <!--- 3.  In need to set the URL to Exchange (stay away from autodsicovery) --->
        <!--- 3a. Create an instance of the Uri class --->
        <cfobject type="Java" class="java.net.URI" name="uri">
        <!--- 3b. Set the full path --->
        <cfset uri.init("https://#myServer#/ews/exchange.asmx")>
        <!--- 3c. Set the url in the service object --->
        <cfset service.setUrl(uri) />

        <!--- These are the steps you need to create valid a service object. --->

        <!--- Now we need to do something with it. --->
        <!--- I create a test message to my own mailbox to see if it works --->
        <cfobject type="Java" action="create" class="microsoft.exchange.webservices.data.EmailMessage" name="message">
        <cfset message = message.init(service) />
        <cfset message.SetSubject("EWSTest")>

        <cfset messageBody = CreateObject("java", "microsoft.exchange.webservices.data.MessageBody")>
        <cfset messageBody.init("My EWS test message")>

        <cfset message.SetBody( messageBody )>

        <cfset message.ToRecipients.Add("#theRecipient#") >


        #message.SendAndSaveCopy()#
    </cfoutput>
</body>

EWS试验
#message.SendAndSaveCopy()#

看看CFexchange标签对我不起作用。无论如何,谢谢。我很好奇,为什么它们不能为您工作?我使用的是CF9、Exchange 2007和EWS API 1.2,并且需要WebDav。托管Exchange服务器的ISP未启用WebDav。第一行告诉它使用一个库,该库将包含代码所需的各种对象,然后是一些。第二行是用服务实例化一个对象,我不知道什么是
服务
,但它是
CreateObject(“component”,blah)
的eqiv。3-6是getter和setter,7保存对象。这就是CFEquiv