WriteTo() public method

Writes the MimeKit.MimePart to the specified output stream.
Writes the MIME part to the output stream.
/// is null. /// -or- /// is null. /// /// The operation was canceled via the cancellation token. /// /// An I/O error occurred. ///
public WriteTo ( MimeKit.FormatOptions options, Stream stream, bool contentOnly, CancellationToken cancellationToken = default(CancellationToken) ) : void
options MimeKit.FormatOptions The formatting options.
stream Stream The output stream.
contentOnly bool true if only the content should be written; otherwise, false.
cancellationToken System.Threading.CancellationToken A cancellation token.
return void
示例#1
4
		public void TestArgumentExceptions ()
		{
			var part = new MimePart ();

			Assert.Throws<ArgumentNullException> (() => new MimePart ((string) null));
			Assert.Throws<ArgumentNullException> (() => new MimePart ((ContentType) null));
			Assert.Throws<ArgumentNullException> (() => new MimePart (null, "octet-stream"));
			Assert.Throws<ArgumentNullException> (() => new MimePart ("application", null));

			Assert.Throws<ArgumentOutOfRangeException> (() => part.ContentDuration = -1);
			Assert.Throws<ArgumentOutOfRangeException> (() => part.Prepare (EncodingConstraint.SevenBit, 1));

			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load ((Stream) null));
			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load ((Stream) null, true));
			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load ((ParserOptions) null, Stream.Null));
			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load (ParserOptions.Default, (Stream) null));
			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load (null, Stream.Null, true));
			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load (ParserOptions.Default, (Stream) null, true));

			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load ((ContentType) null, Stream.Null));
			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load (new ContentType ("application", "octet-stream"), null));
			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load (null, new ContentType ("application", "octet-stream"), Stream.Null));
			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load (ParserOptions.Default, null, Stream.Null));
			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load (ParserOptions.Default, new ContentType ("application", "octet-stream"), null));

			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load ((string) null));
			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load (null, "fileName"));
			Assert.Throws<ArgumentNullException> (() => MimeEntity.Load (ParserOptions.Default, (string) null));

			Assert.Throws<ArgumentNullException> (() => part.Accept (null));
			Assert.Throws<ArgumentNullException> (() => part.WriteTo ((string) null));
			Assert.Throws<ArgumentNullException> (() => part.WriteTo ((Stream) null));
			Assert.Throws<ArgumentNullException> (() => part.WriteTo ((string) null, false));
			Assert.Throws<ArgumentNullException> (() => part.WriteTo ((Stream) null, false));
			Assert.Throws<ArgumentNullException> (() => part.WriteTo (null, Stream.Null));
			Assert.Throws<ArgumentNullException> (() => part.WriteTo (FormatOptions.Default, (Stream) null));
			Assert.Throws<ArgumentNullException> (() => part.WriteTo (null, "fileName"));
			Assert.Throws<ArgumentNullException> (() => part.WriteTo (FormatOptions.Default, (string) null));
			Assert.Throws<ArgumentNullException> (() => part.WriteTo (null, Stream.Null, false));
			Assert.Throws<ArgumentNullException> (() => part.WriteTo (FormatOptions.Default, (Stream) null, false));
			Assert.Throws<ArgumentNullException> (() => part.WriteTo (null, "fileName", false));
			Assert.Throws<ArgumentNullException> (() => part.WriteTo (FormatOptions.Default, (string) null, false));
		}