如何从Exchange检索与已发送文件夹中的电子邮件相关联的extendedProperties

问题描述:

我们使用以下方法在电子邮件上创建了extendedProperties val uId = getUniqueId();

We have created extendedProperties on emails using val uId = getUniqueId();

val emailExtendedPropDef = new ExtendedPropertyDefinition(uId,"uniqueId", MapiPropertyType.String)
    try {
      email.setExtendedProperty(emailExtendedPropDef, uId.toString)
      email.sendAndSaveCopy()
    } catch {
      case e: Exception =>
        error(s"Exception in setting extended property for user $from", e)
        throw e
    }

现在,我们要遍历已发送文件夹中的电子邮件,并遍历已设置电子邮件的扩展属性

Now we want to iterate over the emails in sent folder and go over the extendedProperties for the emails that have been set

val view = new ItemView(1000)
    var extendedPropertyIndex = 0
    var bodyList = new ListBuffer[String]()
    val propertySet = new PropertySet(BasePropertySet.FirstClassProperties

    try {
      val findResults = service.findItems(WellKnownFolderName.SentItems, view)
      if (findResults.getTotalCount > 0) {
        val iterator = findResults.getItems().iterator()

        while(iterator.hasNext) {

          val item = iterator.next()

          val extendedPropertyCollection = item.getExtendedProperties()

          println("count is "+extendedPropertyCollection.getCount())
          if (extendedPropertyCollection.getCount() > 0)
          {
               //do some processing

          }
       }
     }
    } 

我们能够成功检索项目,但是不确定其扩展属性

尽管我们知道这些项目我们已经使用上述逻辑设置了extendedProperty,但我们一直将计数设为 0 ……

We have been getting the count as 0 eventhough we know for these items we have set the extendedProperty using the above logic ......

如果有人能指出正确的方向,为什么我们收到扩展属性0计数,这也是非常有帮助的,而且我们的要求是检索所有设置了extendedProperties的电子邮件

It will be of great help if someone could point us in the right direction on why we are receiving 0 count for the extended properties and also our requirement is to retrieve all the emails with extendedProperties set

更新:尝试了以下选项

val emailIdPropDef = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings,"uniqueId", MapiPropertyType.String)
    val propertySet = new PropertySet(BasePropertySet.FirstClassProperties, emailIdPropDef)


    view.setPropertySet(propertySet)

但是仍然没有运气,任何朝着正确方向的指针都会有很大帮助

But still no luck any pointer in the right direction will be of great help

Exchange将仅返回您要求其返回的扩展属性.因此,您需要将扩展​​属性添加到在FindItems操作中使用的PropertySet中,如果在FindItem返回的任何对象上都设置了扩展属性,则它将返回该属性.例如,此属性

Exchange will only return the extended properties you request it to return. So you need to add the extended property to the PropertySet your using in the FindItems operation and it will then get returned if it has been set on any objects that FindItem returns.eg this property

val emailExtendedPropDef = new ExtendedPropertyDefinition(uId,"uniqueId", MapiPropertyType.String)

需要添加到此属性集

val propertySet = new PropertySet(BasePropertySet.FirstClassProperties)

,该属性集应在此ItemView上使用

and that property set should be used on this ItemView

val view = new ItemView(1000)
val.PropertySet = propertySet