ToString() public method

Returns a System.String that represents the current MailKit.Envelope.

The returned string can be parsed by TryParse(string,out Envelope).

The syntax of the string returned, while similar to IMAP's ENVELOPE syntax, is not completely compatible.
public ToString ( ) : string
return string
Example #1
0
		public void TestSerialization ()
		{
			var original = new Envelope ();
			original.Bcc.Add (new MailboxAddress ("Bcc Recipient", "*****@*****.**"));
			original.Cc.Add (new MailboxAddress ("Routed Mailbox", new string[] { "domain.org" }, "*****@*****.**"));
			original.Date = DateTimeOffset.Now;
			original.From.Add (new MailboxAddress ("MailKit Unit Tests", "*****@*****.**"));
			original.InReplyTo = "<*****@*****.**>";
			original.MessageId = "<*****@*****.**>";
			original.ReplyTo.Add (new MailboxAddress ("Reply-To", "*****@*****.**"));
			original.Sender.Add (new MailboxAddress ("The Real Sender", "*****@*****.**"));
			original.Subject = "This is the subject";
			original.To.Add (new GroupAddress ("Group Address", new MailboxAddress[] {
				new MailboxAddress ("Recipient 1", "*****@*****.**"),
				new MailboxAddress ("Recipient 2", "*****@*****.**")
			}));
			var text = original.ToString ();
			Envelope envelope;

			Assert.IsTrue (Envelope.TryParse (text, out envelope));
			var text2 = envelope.ToString ();

			Assert.AreEqual (text, text2);
		}