MimeKit.Header.SetValue C# (CSharp) Method

SetValue() public method

Sets the header value using the specified formatting options and character encoding.
When a particular charset is desired for encoding the header value according to the rules of rfc2047, this method should be used instead of the Value setter.
/// is null. /// -or- /// is null. /// -or- /// is null. ///
public SetValue ( MimeKit.FormatOptions format, Portable.Text.Encoding encoding, string value ) : void
format MimeKit.FormatOptions The formatting options.
encoding Portable.Text.Encoding A character encoding.
value string The header value.
return void
		public void SetValue (FormatOptions format, Encoding encoding, string value)
		{
			if (format == null)
				throw new ArgumentNullException (nameof (format));

			if (encoding == null)
				throw new ArgumentNullException (nameof (encoding));

			if (value == null)
				throw new ArgumentNullException (nameof (value));

			textValue = Unfold (value.Trim ());

			rawValue = FormatRawValue (format, encoding);

			// cache the formatting options that change the way the header is formatted
			//allowMixedHeaderCharsets = format.AllowMixedHeaderCharsets;
			//newLineFormat = format.NewLineFormat;
			//international = format.International;
			//charset = encoding;

			OnChanged ();
		}

Same methods

Header::SetValue ( MimeKit.FormatOptions format, string charset, string value ) : void
Header::SetValue ( Portable.Text.Encoding encoding, string value ) : void
Header::SetValue ( string charset, string value ) : void

Usage Example

Ejemplo n.º 1
0
		public void TestReceivedHeaderFolding ()
		{
			var header = new Header ("Received", "");

			foreach (var received in ReceivedHeaderValues) {
				header.SetValue (Encoding.ASCII, received.Replace (FormatOptions.Default.NewLine + "\t", " ").Trim ());

				var raw = ByteArrayToString (header.RawValue);

				Assert.IsTrue (raw[raw.Length - 1] == '\n', "The RawValue does not end with a new line.");

				Assert.AreEqual (received + FormatOptions.Default.NewLine, raw, "The folded Received header does not match the expected value.");
			}
		}
All Usage Examples Of MimeKit.Header::SetValue