In my application, I have a form with textarea. If a user keeps typing endlessly without using whitespace to divide the content, the submitted input value end up being one extremely long string without any whitespace. As a result, when I send this content in an email, I receive an email that is longer than the width of my screen.
How could I divide the string into smaller parts?
Use a StringReader to read the input string, a StringBuilder to write the mail content.
Read
xchars into a char array, append this array to the StringBuilder, rinse, repeat until there isn’t anything to read anymore.However this will break words. Which means you probably need to refine this process by finding the last index of a space character. StringReader supports
mark()andreset(), use this.