internal static ItemBody GetEntityBody(this IItem input, char[] buffer) { Body body; BodyType bodyType; try { body = IrmUtils.GetBody(input); BodyFormat format = body.Format; bodyType = format.ToEntityType(); } catch (PropertyErrorException ex) { ExTraceGlobals.CommonTracer.TraceDebug <string, string>(0L, "[BodyConverter::GetEntityBody] Encountered exception - Class: {0}; Message: {1}", ex.GetType().FullName, ex.Message); throw new CorruptDataException(Strings.ErrorItemCorrupt, ex); } catch (StoragePermanentException ex2) { if (ex2.InnerException is MapiExceptionNoSupport) { throw new CorruptDataException(Strings.ErrorItemCorrupt, ex2); } ExTraceGlobals.CommonTracer.TraceDebug(0L, "[BodyConverter::GetEntityBody] Encountered exception - Class: {0}, Message: {1} Inner exception was not MapiExceptionNoSupport but rather Class: {2}; Message: {3}", new object[] { ex2.GetType().FullName, ex2.Message, (ex2.InnerException == null) ? "<NULL>" : ex2.InnerException.GetType().FullName, (ex2.InnerException == null) ? "<NULL>" : ex2.InnerException.Message }); throw; } ItemBody itemBody = new ItemBody { ContentType = bodyType }; using (TextWriter textWriter = new StringWriter()) { if (bodyType == BodyType.Html) { BodyConverter.WriteHtmlContent(textWriter, input, buffer); } else { BodyConverter.WriteTextContent(textWriter, body, buffer); } itemBody.Content = textWriter.ToString(); } return(itemBody); }