0

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

          }
       }
     }
    } 

We are able to successfully retrieve the items but not their extended properties not sure why

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

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

Update : tried with these options

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

user2359997
  • 561
  • 1
  • 16
  • 40

1 Answers1

0

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)

needs to be added to this Propertyset

val propertySet = new PropertySet(BasePropertySet.FirstClassProperties)

and that property set should be used on this ItemView

val view = new ItemView(1000)
val.PropertySet = propertySet
Glen Scales
  • 20,495
  • 1
  • 20
  • 23
  • Thank you very much for your answer Glen ! We wish we had the uid values , but we don't have the uid value ...we are iterating over the sent items and checking if they have external properties and then if they do we need to delete them is our use case ...is there any other way to retrieve the extendedProperties associated with the item ? – user2359997 Jun 14 '18 at 00:47
  • Not with EWS because you always need to define the properties as it doesn't have any methods that allow enumeration of Props, you can do this in MAPI i guess your trying to cleanup and stop using Uid's based on your other question. My suggestion would be use Redemption http://www.dimastr.com/redemption/RDOMail.htm which will use Outlook's MAPI provider which would then allow you to enumerate every prop on a Message. You can look at particular Item using a Mapi editor like MFCMapi our Outlook Spy to see what you can get with MAPI. – Glen Scales Jun 14 '18 at 03:08
  • yes exactly Glen ! thank you ! we are trying to clean up the Uids as mentioned in the other question , i looked at the Redemption and OutLook spy from the link you shared they look like ideal tools to what we want to achieve, but from what i looked they both need installation's on users side .....please correct me if i'm wrong in my assumption, if you could please suggest any programatic way to achieve this without need for installation on user side it will be of great help – user2359997 Jun 14 '18 at 03:29
  • You don't need to have it on the users side eg you just need one workstation with Redemption and Outlook and then you can connect to any Mailbox on an Exchange Server (as long as you have Full Mailbox access to that Mailbox) – Glen Scales Jun 15 '18 at 02:27
  • Thanks Glen ! we have identified the uuid using outlook spy and deleted them (about 40) ....but still getting the same invalid property exception when sending emails ...could you please help – user2359997 Jun 19 '18 at 18:15