none
Setting PR_CONVERSATION_INDEX (PidConversationIndex) and PR_CONVERSATION_TOPIC (PidTagConversationTopic) through EWS APIs

    Question

  • Hi all,

    I'd like to find out whether or not it's possible to set item specific MAPI
    properties through EWS. To be more specific, what I'm trying to do is set
    the PR_CONVERSATION_INDEX (PidTagConversationIndex) and the PR_CONVERSATION_TOPIC (PidTagConversationTopic)
    property associated with an email before I send it out in my application.

    I have the following code written (in Java) to try to accomplish the conversation topic part but it doesn't seem to do anything. I know this because when I try to sort by conversation in OWA I don't see the messages being sorted by the conversation topic that I'm setting but rather they're sorted in the default way - by the subject of the message. Does anyone know what I might be doing wrong?
    		PathToExtendedFieldType convTopicPath = PathToExtendedFieldType.Factory.newInstance();		
    		convTopicPath.setPropertyTag("0x0070");
    		convTopicPath.setPropertyType(MapiPropertyTypeType.STRING);
    		ExtendedPropertyType extendedPropType = ExtendedPropertyType.Factory.newInstance();
    		extendedPropType.setExtendedFieldURI(convTopicPath);
    		extendedPropType.setValue(convTopic);
    		message.setExtendedPropertyArray(new ExtendedPropertyType[] {extendedPropType});

    Also looks like there is an API to set the conversation topic and conversation index of an object of "MessageType" but when I try to set it as such I get an error saying "Set action is invalid for property". I imagine this might be because both ConversationTopic and ConversationIndex are read-only but then that makes me wonder why the API to set these attributes exists at all?
    		MessageType message = MessageType.Factory.newInstance();
    		message.setConversationTopic("convTopic");

    Any help with this matter would be greatly appreciated.

    Thanks,

    Nitin
    Friday, April 17, 2009 9:24 PM

All replies

  • Hello Nitin,

    In short, yes, it is possible to set item specific MAPI properties. Refer to your thread http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/b0f9bbf4-5450-45c7-a2fb-1ef5300d1b49 which contains an XML snippet that demonstrates the XML structure for setting the PR_CONVERSATION_INDEX on an email.

    Can you share with us the XML request and response so that we can better understand what is being sent over the wire? Are you receiving an error message and if so, what is it?

    With regards,


    Michael | Microsoft Exchange SDK
    Friday, April 17, 2009 10:18 PM
    Moderator
  • Hi Michael,

    I had no idea you had replied to my other post. Thanks very much for the response but I still haven't been able to resolve my problem as yet.

    I've pasted the request that goes out when I try to create a message and set the conversation topic. This seems to align well with the xml that you included in your other post. However, I don't see the expected result when I try to sort the messages in my inbox by conversation. Do you see notice any issues in the my request XML?

    Also while we're at it, I'd also like to know if there is any tool that I can use to examine the MAPI properties associated with an item in EWS. Sort of like MFCMAPI but for EWS? Essentially I'd like to find out if I'm receiving the correct MAPI values when I receive the message.

    THE REQUEST ********************************************************

    <CreateItem MessageDisposition="SendAndSaveCopy" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types">
      <SavedItemFolderId>
        <typ:DistinguishedFolderId Id="sentitems"/>
      </SavedItemFolderId>
      <Items>
        <typ:Message>
          <typ:Subject>SUBJECT</typ:Subject>
          <typ:Body BodyType="HTML">CONTENT</typ:Body>
          <typ:ExtendedProperty>
            <typ:ExtendedFieldURI PropertyTag="0x0070" PropertyType="String"/>
            <typ:Value>convTopic</typ:Value>
          </typ:ExtendedProperty>
          <typ:ToRecipients>
            <typ:Mailbox>
              <typ:EmailAddress>ctmewsuser@ewsdev.com</typ:EmailAddress>
            </typ:Mailbox>
          </typ:ToRecipients>
          <typ:IsRead>false</typ:IsRead>
        </typ:Message>
      </Items>
    </CreateItem>

    THE RESPONSE ********************************************************

    <m:CreateItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <m:ResponseMessages>
        <m:CreateItemResponseMessage ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
          <m:Items/>
        </m:CreateItemResponseMessage>
      </m:ResponseMessages>
    </m:CreateItemResponse>
    Saturday, April 18, 2009 12:21 AM
  • Hello Nitin,

    The request you just posted above is setting the PR_CONVERSATION_TOPIC property. Have you also set the PR_CONVERSATION_INDEX property?

    Regards,
    Kim Brandl
    Programming Writer, Microsoft Exchange Developer Documentation Team
    Saturday, April 18, 2009 12:52 AM
  • Hi Kim,

    Yes, I did try setting both the conversation topic and conversation index and that didn't seem to make any difference either. Btw, I have confirmed (using Outlook 2003 and WebDav) that it is possible to sort by conversation when only the conversation topic is set. In any case, I'm going to go ahead and paste the request, response and the Java method I use to send my email, just in case any of it helps. Please do get back to me and let me know if you can see anything that's amiss. Also, I would like to reiterate my request for a MFCMAPI like tool that I can use to examine the MAPI attributes of messages in an EWS inbox. Please let me know if you are aware of such a tool.

    Thanks,

    Nitin

    THE REQUEST ********************************************************

    <CreateItem MessageDisposition="SendAndSaveCopy" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types">
      <SavedItemFolderId>
        <typ:DistinguishedFolderId Id="sentitems"/>
      </SavedItemFolderId>
      <Items>
        <typ:Message>
          <typ:Subject>SUBJECT</typ:Subject>
          <typ:Body BodyType="HTML">CONTENT</typ:Body>
          <typ:ExtendedProperty>
            <typ:ExtendedFieldURI PropertyTag="0x0070" PropertyType="String"/>
            <typ:Value>convTopic</typ:Value>
          </typ:ExtendedProperty>
          <typ:ExtendedProperty>
            <typ:ExtendedFieldURI PropertyTag="0x0071" PropertyType="Binary"/>
            <typ:Value>Acm5V5HS1wR4VjynTOGlZ1PCflvzEwAAu6WQAKmSqCAAACNbIAAcp9oAAGCSvzA=</typ:Value>
          </typ:ExtendedProperty>
          <typ:ToRecipients>
            <typ:Mailbox>
              <typ:EmailAddress>ctmewsuser@ewsdev.com</typ:EmailAddress>
            </typ:Mailbox>
          </typ:ToRecipients>
          <typ:IsRead>false</typ:IsRead>
        </typ:Message>
      </Items>
    </CreateItem>

    THE RESPONSE ********************************************************

    <m:CreateItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <m:ResponseMessages>
        <m:CreateItemResponseMessage ResponseClass="Success">
          <m:ResponseCode>NoError</m:ResponseCode>
          <m:Items/>
        </m:CreateItemResponseMessage>
      </m:ResponseMessages>
    </m:CreateItemResponse>

    THE METHOD *********************************************************
        public static void sendMailContent(String[] emailParts, String username, String password, CTMExchangeService ces) {

            String recipient = "ctmewsuser@ewsdev.com";
            String subject = "SUBJECT";
            String content = "CONTENT";
            String convTopic = "convTopic";
            //String content_type = emailParts[3];
            String emailAddressToBeCopied = null;

            CreateItemDocument request = CreateItemDocument.Factory.newInstance();
            CreateItemType createItem = CreateItemType.Factory.newInstance();

            //specify the operation
            createItem.setMessageDisposition(MessageDispositionType.SEND_AND_SAVE_COPY);

            //specify the folder to save
            DistinguishedFolderIdType distinguishedFolderId = DistinguishedFolderIdType.Factory.newInstance();
            distinguishedFolderId.setId(DistinguishedFolderIdNameType.SENTITEMS);

            TargetFolderIdType targetFolder = TargetFolderIdType.Factory.newInstance();
            targetFolder.setDistinguishedFolderId(distinguishedFolderId);
            createItem.setSavedItemFolderId(targetFolder);

            //specify the contents
            NonEmptyArrayOfAllItemsType items = NonEmptyArrayOfAllItemsType.Factory.newInstance();
            MessageType message = MessageType.Factory.newInstance();
            message.setSubject(subject);

            BodyType bodyType = BodyType.Factory.newInstance();
            bodyType.setBodyType(BodyTypeType.HTML);
            bodyType.setStringValue(content);
            message.setBody(bodyType);

            //mark it un read
            message.setIsRead(false);

            //set recipient
            {
                EmailAddressType emailAddress = EmailAddressType.Factory.newInstance();
                emailAddress.setEmailAddress(recipient);
                ArrayOfRecipientsType toRecipients = ArrayOfRecipientsType.Factory.newInstance();
                toRecipients.setMailboxArray(new EmailAddressType [] {emailAddress});
                message.setToRecipients(toRecipients);
            }

            //set bcc
            if(emailAddressToBeCopied != null && emailAddressToBeCopied.length() > 0 && username == null
                    && password == null) {
                EmailAddressType emailAddress = EmailAddressType.Factory.newInstance();
                emailAddress.setEmailAddress(emailAddressToBeCopied);
                ArrayOfRecipientsType toRecipients = ArrayOfRecipientsType.Factory.newInstance();
                toRecipients.setMailboxArray(new EmailAddressType [] {emailAddress});
                message.setBccRecipients(toRecipients);
            }

            //set conversation topic
            PathToExtendedFieldType convTopicPath = PathToExtendedFieldType.Factory.newInstance();       
            convTopicPath.setPropertyTag("0x0070");
            convTopicPath.setPropertyType(MapiPropertyTypeType.STRING);           
            System.out.println("PATHTO_EXTENDED_FIELD_TYPE -----------------------------------");
            System.out.println(convTopicPath);               
            ExtendedPropertyType extendedPropType = ExtendedPropertyType.Factory.newInstance();
            extendedPropType.setExtendedFieldURI(convTopicPath);
            extendedPropType.setValue(convTopic);
           
            //set conversation index
            PathToExtendedFieldType convIndexPath = PathToExtendedFieldType.Factory.newInstance();       
            convIndexPath.setPropertyTag("0x0071");
            System.out.println("PATHTO_EXTENDED_FIELD_TYPE_2 -----------------------------------");
            System.out.println(convIndexPath);
            convIndexPath.setPropertyType(MapiPropertyTypeType.BINARY);
            ExtendedPropertyType extendedPropType2 = ExtendedPropertyType.Factory.newInstance();
            extendedPropType2.setExtendedFieldURI(convIndexPath);
            extendedPropType2.setValue("Acm5V5HS1wR4VjynTOGlZ1PCflvzEwAAu6WQAKmSqCAAACNbIAAcp9oAAGCSvzA=");
           
            message.setExtendedPropertyArray(new ExtendedPropertyType[] {extendedPropType, extendedPropType2});   

            items.setMessageArray(new MessageType[] {message});

            //add the message to the item list
            createItem.setItems(items);

            request.setCreateItem(createItem);

            System.out.println("THE REQUEST ********************************************************");
            System.out.println();
            System.out.println(request);
            CreateItemResponseDocument response = null;
            try {
                if(ces != null){
                    response = ces.CreateItem(request, null, null, null, EWSGeneralUtil.getServerVersionDocument());

                    ItemInfoResponseMessageType itemInfo =
                        response.getCreateItemResponse().getResponseMessages().getCreateItemResponseMessageArray(0);
                    System.out.println("THE RESPONSE ********************************************************");
                    System.out.println();
                    System.out.println(response);
                }
            } catch(Exception e) {
            }

        }
    Monday, April 20, 2009 7:17 PM
  • Also, I would like to reiterate my request for a MFCMAPI like tool that I can use to examine the MAPI attributes of messages in an EWS inbox. Please let me know if you are aware of such a tool.


    ...EWSEditor is the tool you are looking for: http://code.msdn.microsoft.com/ewseditor
    Thursday, February 18, 2010 4:03 PM