MimeKit.MultipartAlternative.GetTextBody C# (CSharp) Method

GetTextBody() public method

Get the text body in the specified format.
Gets the text body in the specified format, if it exists.
public GetTextBody ( TextFormat format ) : string
format TextFormat The desired text format.
return string
		public string GetTextBody (TextFormat format)
		{
			// walk the multipart/alternative children backwards from greatest level of faithfulness to the least faithful
			for (int i = Count - 1; i >= 0; i--) {
				var alternative = this[i] as MultipartAlternative;

				if (alternative != null) {
					// Note: nested multipart/alternative parts make no sense... yet here we are.
					return alternative.GetTextBody (format);
				}

				var related = this[i] as MultipartRelated;
				var text = this[i] as TextPart;

				if (related != null) {
					var root = related.Root;

					alternative = root as MultipartAlternative;
					if (alternative != null)
						return alternative.GetTextBody (format);

					text = root as TextPart;
				}

				if (text != null && text.IsFormat (format))
					return GetText (text);
			}

			return null;
		}
	}