EWS API和ColdFusion:如何引用返回值 [英] EWS API and ColdFusion: How to reference returned values
问题描述
我有困难与复杂的阵列工作,可以使用一些帮助。我与EWS API合作与Exchange 2010和CF整合邮件功能下面的code连接到主账户已经授权给一个邮箱。我想在收件箱中返回的邮件列表,并与EWS返回值工作(主题行,正文,发件人,收件人,等等)。
I am having difficulty working with complex arrays and could use some help. I am working with the EWS API to integrate mail functions with Exchange 2010 and CF. The code below connects to a mailbox that the primary account has delegated authority to. I want to return a list of messages in the inbox and work with the values that EWS returns (subject line, body, from, to, etc).
我没有复杂的数组像这样工作过,所以我困惑如何引用返回的值,特别是getItems内被FindItemsResults()方法返回。我看过一个Java示例,这样做同样的工作,但我有让我的头脑围绕如何这相当于CF.包裹麻烦CFDump显示,我收到信息后,所以我相信,连接是否正常工作按预期。我只需要获得数据,不知道该怎么做。
I have not worked with complex arrays like this before, so I'm confused about how to reference the values returned, specifically within the getItems() method that is returned in FindItemsResults. I have looked a Java examples that do this same task, but I'm having trouble getting my mind wrapped around how this translates to CF. CFDump shows that I am getting information back, so I'm confident that the connection is working as intended. I just need to get at the data and don't know how to do it.
感谢您事先的任何帮助。
Thanks in advance for any help.
<cfobject type="Java" class="microsoft.exchange.webservices.data.ExchangeService" name="service">
<cfset service.init()>
<cfobject type="Java" class="microsoft.exchange.webservices.data.WebCredentials" name="credentials">
<cfset credentials.init("username","password", "domain")>
<cfset service.setCredentials(credentials) />
<cfset service.AutodiscoverUrl("email@domain.com")>
<cfobject type="java" class="microsoft.exchange.webservices.data.WellKnownFolderName" name="WellKnownFolderName">
<cfset ViewResults = service.findItems(CreateObject("java","microsoft.exchange.webservices.data.FolderId").init(WellKnownFolderName.Inbox,
CreateObject("java","microsoft.exchange.webservices.data.Mailbox").init("othermail@domain.com","SMTP")),
CreateObject("java","microsoft.exchange.webservices.data.ItemView").init(3)) />
<cfdump var="#ViewResults#">
<cfdump var="#ViewResults.getItems()#">
推荐答案
(从评论...)
因此,它看起来像 ViewResults.getItems()
返回 EmailMessage
对象的数组。 EmailMessage有一堆的方法。一些简单的返回值(布尔,字符串,..)和其他类似 GETFROM()
返回复杂的对象。
So it looks like ViewResults.getItems()
returns an array of EmailMessage
objects. EmailMessage has a bunch of methods. Some return simple values (boolean, string, ..) and others like getFrom()
return complex objects.
试着做一个数组循环和里面一样简单属性的输出之一: getIsRead()
或 getReferences()
。即
Try doing an array loop and inside it output one of the simple properties like: getIsRead()
or getReferences()
. ie
<cfloop array="#itemsArray#" index="message">
<cfdump var="#message.getIsRead()#" label="getIsRead()">
<cfdump var="#message.getReferences()#" label="getReferences()">
</cfloop>
如果这样的作品,尝试调用 GETFROM()
返回一个 EmailAddress的
对象。检查API,但它看起来像您可以使用访问地址值之一:
If that works, try calling getFrom()
which returns an EmailAddress
object. Check the API, but it looks like you can access the address value using either:
#message.getFrom().getAddress()# ... or
#message.getFrom().get_Address()#
(你的想法...)
(You get the idea ...)
这篇关于EWS API和ColdFusion:如何引用返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!