String encoding odd format when displayed

skin256

New member
Joined
Nov 19, 2009
Messages
1
Programming Experience
3-5
Hi and thanks in advance for any help offered, and aplogies if this was posted to the wrong forums.

I have a in my mind complicated scenario but I will try to spell it out as best as possible.



I created a 3.5 console application that monitors various Exchange accounts using the EWS API.

When an email arrives it will take the body of the email in Text format and place it into a string.

It will then with other properties insert into our vendor database SQL 2005 (outside of our control) field the strings taken from the message.

The problem I am having is that the field it is inserting into is a TEXT datatype and what is happening is that when the body of this email is viewed through our vendor provided application it is 'smashed' and hard to read. This only happens on the email strings my application inserts. I have done testing of sending the email to an account that the vendor app watches and it can display that body just fine, which leads me to believe they do some other string preperation that I am not doing.

I am taking a stab after much reading that because the string is Unicode(UTF-16) that the TEXT field cannot 'interpret' things like line breaks etc and that is what happens, I get 'squares' and smashed text (very poorly formatted). This even happens when using Visual Studios Text Viewer on my string but outputting it to console or a word document it is formatted perfectly.

Outside of converting the fields to nvarchar or ntext what could I do? There really is no magic as to what I am doing here is the one line of code where I get the email body using EWS API.


_lclInboxItem.InboxItemBody = mt.Body.Value.ToString

In the procedure that inserts into the database the parameter type is text to match the field in the table.

At a loss and would GREATLY appreciate any ideas. I hope this makes sense and will gladly provide more information or code sample if requested.



MTIA

Jeremy
 
Back
Top