When accessing a multi line text field from a SharePoint item in a list, what is the text type returned?

Using C#:


Is the above plaintext or html or...?

I want to format the text to be put in a HTML email ultimately, but all formatting of the string in the actual description is lost when doing so.

  • What option did you choose? Rich text or Enhanced rich text? Usually you get html formatted text all the time if you choose rich text for multi line text column – Diptarag Dec 20 '12 at 6:18
  • I believe enhanced rich text. There were some benefits to it in terms of the WYSIWYG editing. I forget what those were now. – cbrad Dec 20 '12 at 16:16

You may have to change the description column using Powershell to include HTML.

$Web = Get-SPWeb "yoururl.domain.com/particularweb"
$Field = $web.Fields | ?{$_.staticname -eq "MyCustomColumn"}
$Field.RichText = $True
$Field.RichTextMode = "FullHtml"

Source: http://social.technet.microsoft.com/Forums/nl-NL/sharepointadminprevious/thread/a6d1b087-4d06-4e8f-8f69-043e15b04819

EDIT: Try this:

SPFieldMultiLineText multilineField = item.Fields.GetField(COLUMN_NAME) as SPFieldMultiLineText;

 if (multilineField != null)
 // Get the field value as HTML
 string text = multilineField.GetFieldValueAsHtml(item[COLUMN_NAME], item);

Source: http://blog.myitechnology.com/2009/06/append-new-line-to-spfieldmultilinetext.html

  • Hmm, it looks like this just changes the text fields to rich text, which allows HTML etc. I do already have my fields set up as rich text with HTML enabled. I'm just wondering when you pull data from fields programmatically, how those strings are formatted. – cbrad Dec 19 '12 at 23:05
  • I updated my answer. – Mike Dec 20 '12 at 14:30
  • That looks like it will work I'll give it a try, thanks. You also updated your gravatar! – cbrad Dec 20 '12 at 16:13
  • Why yes, yes I did. Let me know if that works for you! – Mike Dec 20 '12 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.