我刚刚升级到Exchange 2013.我可以代表其他Exchange用户连接并发送电子邮件。但是我无法代表其他用户插入日历活动。我正在使用Coldfusion 9和EWS API。
我得到错误; 系统试图在代码或某些系统代码中使用未定义的值,这通常表示编程错误。
它指着这条线; appt.Start =' #CreateDateTime(2014,05,05,09,00,00)#'
我可以硬编码日期/时间仅用于测试目的吗?
我已经尝试过; appt.Start =' 2014/05/05 09:00:00' 但是我得到了同样的错误。
<cfobject type="Java" class="microsoft.exchange.webservices.data.ExchangeService" name="service">
<cfset service.init()>
<cfobject type="Java" class="microsoft.exchange.webservices.data.ExchangeVersion" name="version">
<cfset service.init(version.Exchange2010)>
<cfobject type="Java" class="microsoft.exchange.webservices.data.WebCredentials" name="credentials">
<cfset credentials.init("v@t.com","password")>
<cfset service.setCredentials(credentials) />
<cfobject type="Java" class="java.net.URI" name="uri">
<cfset uri.init("https://exch999.serverdata.net/EWS/Exchange.asmx?wsdl")>
<cfset service.setUrl(uri) />
以下代码已编辑为解决方案
<cfoutput>
<cfobject type="Java" class="microsoft.exchange.webservices.data.Appointment" name="appointment">
<cfset appointment.init( service )>
<cfobject type="Java" class="microsoft.exchange.webservices.data.MessageBody" name="MessageBody">
<!--- <cfset MessageBody.init( service )> --->
<cfscript>
appointment.setStart(#createDateTime(Year(Arguments.EventStartDateTime), Month(Arguments.EventStartDateTime),Day(Arguments.EventStartDateTime), evaluate(Hour(Arguments.EventStartDateTime) - val(attributes.AdminTimeZone)), Minute(Arguments.EventStartDateTime), 0)#);
appointment.setEnd(#createDateTime(Year(Arguments.EventEndDateTime), Month(Arguments.EventEndDateTime),Day(Arguments.EventEndDateTime), evaluate(Hour(Arguments.EventEndDateTime) - val(attributes.AdminTimeZone)), Minute(Arguments.EventEndDateTime), 0)#);
/*appointment.StartTimeZone(TimeZoneInfo.Local);
appointment.EndTimeZone(TimeZoneInfo.Local);*/
appointment.setSubject("#Arguments.EventName#");
appointment.setBody(MessageBody.getMessageBodyFromText("#Arguments.EventDescription#"));
/*appointment.IsReminderSet(false);*/
appointment.Save();
</cfscript>
</cfoutput>