locked
EWS - Replace text in appointment body that contains <br /> RRS feed

  • Question

  • Hi All,

    I'm using EWS to populate an appointment body with details of events.  The value I pass through on creation of an event is formatted like this (note: the appointment itself is already present in exchange):

    <p>Name<br />Address<br />score</p>

    This works and is formatted in outlook as I'd like:

    Name

    Address

    Score

    There may be multiple event details added to one exchange appointment which are listed below each other but added separately:

    Name

    Address

    Score

    Name

    Address

    Score

    This also works without an issue.

    The problem is when I come to remove event details using a replace function (where appointmentText is the original string - "<p>Name<br />Address<br />score</p>") e.g.:

    appointment.body.ToString().replace(appointmentText,"");

    The text is not being replaced.

    If I pass through a single line of text without the tags to format the details the replace works correctly but the text is less user friendly to read in the outlook appointment.

    My assumption is that something happens to the string formatting after I've called the EWS but I don't know what.  I've read a little about exchange converting it to RTF.  If this is the case, are there any formatting conversion methods I can use on the appointmentText string to allow the replace function to find the string in the body?


    Thursday, August 6, 2015 12:36 PM

All replies

  • hi,

     

    yes you are right, working with bodies in exchange is not an easy task. If i understand you correctly, you want to populate an existing item with additional information and later you want to clean up the item.

    I think that you can not "Find -> Replace" the additional information you inserted into the object. You will have to find a workaround that helps you to complete the task.

    If you add the information always at the beginning of your appointment, you could set a delimiter between your data and the original text. Then you can cut off all of the text above the defined delimiter.

    This technique would work for HTML-Bodies and for Text-Bodies.

    If you add the information inline on different positions, you could try to add an custom html- or custom id-Tag, to identify the beginning and ending of your additional information block. To clean up the appointment you would have to search for your Tag/Id and remove the complete block.

    As mentioned these are workarounds and not a “real” solution. It will be always possible that someone changes the Body-Value and you will always fail to find your additional information.

    You could create a “solid” solution by creation an attachment that contains the data you want to provide to the user.

    hth

    Julian

    --

    zubIT-SQL-ExchangeSync 

    Thursday, April 21, 2016 2:04 PM