当前位置: 首页>>代码示例>>C#>>正文


C# Message.FindFirstMessagePartWithMediaType方法代码示例

本文整理汇总了C#中OpenPop.Mime.Message.FindFirstMessagePartWithMediaType方法的典型用法代码示例。如果您正苦于以下问题:C# Message.FindFirstMessagePartWithMediaType方法的具体用法?C# Message.FindFirstMessagePartWithMediaType怎么用?C# Message.FindFirstMessagePartWithMediaType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenPop.Mime.Message的用法示例。


在下文中一共展示了Message.FindFirstMessagePartWithMediaType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindXmlInMessage

		/// <summary>
		/// Example showing:
		///  - how to find a MessagePart with a specified MediaType
		///  - how to get the body of a MessagePart as a string
		/// </summary>
		/// <param name="message">The message to examine for xml</param>
		public static void FindXmlInMessage(Message message)
		{
			MessagePart xml = message.FindFirstMessagePartWithMediaType("text/xml");
			if (xml != null)
			{
				// Get out the XML string from the email
				string xmlString = xml.GetBodyAsText();

				System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

				// Load in the XML read from the email
				doc.LoadXml(xmlString);

				// Save the xml to the filesystem
				doc.Save("test.xml");
			}
		}
开发者ID:JoshKeegan,项目名称:hpop,代码行数:23,代码来源:Examples.cs

示例2: TestGetFirstMessageWithMediaTypeSimpleNotFound

        public void TestGetFirstMessageWithMediaTypeSimpleNotFound()
        {
            const string rfcExample =
                "Content-type: text/plain; charset=us-ascii\r\n" +
                "\r\n" +
                "This is explicitly typed plain US-ASCII text";

            Message message = new Message(Encoding.ASCII.GetBytes(rfcExample));

            MessagePart part = message.FindFirstMessagePartWithMediaType("text/html");

            // We should not be able to find such a MessagePart
            Assert.Null(part);
        }
开发者ID:bitspill,项目名称:Gridcoin-master,代码行数:14,代码来源:MessageTest.cs

示例3: TestGetFirstMessageWithMediaTypeMultiPartFoundSecond

        public void TestGetFirstMessageWithMediaTypeMultiPartFoundSecond()
        {
            const string rfcExample =
                "From: Nathaniel Borenstein <[email protected]>\r\n" +
                "To: Ned Freed <[email protected]>\r\n" +
                "Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\r\n" +
                "Subject: Sample message\r\n" +
                "MIME-Version: 1.0\r\n" +
                "Content-type: multipart/mixed; boundary=\"simple boundary\"\r\n" +
                "\r\n" +
                "--simple boundary\r\n" +
                "\r\n" +
                "TEXT\r\n" +
                "--simple boundary\r\n" +
                "Content-type: text/html; charset=ISO-8859-1\r\n" +
                "\r\n" +
                "HTML\r\n" +
                "--simple boundary--";

            Message message = new Message(Encoding.ASCII.GetBytes(rfcExample));

            MessagePart part = message.FindFirstMessagePartWithMediaType("text/html");

            Assert.NotNull(part);
            Assert.AreEqual("text/html", part.ContentType.MediaType);
            Assert.AreEqual("ISO-8859-1", part.ContentType.CharSet);
            Assert.AreEqual(Encoding.GetEncoding("ISO-8859-1"), part.BodyEncoding);
            Assert.AreEqual("HTML", part.GetBodyAsText());
        }
开发者ID:bitspill,项目名称:Gridcoin-master,代码行数:29,代码来源:MessageTest.cs

示例4: TestGetFirstMessageWithMediaTypeSimpleFoundHTML

        public void TestGetFirstMessageWithMediaTypeSimpleFoundHTML()
        {
            const string rfcExample =
                "Content-type: text/html; charset=us-ascii\r\n" +
                "\r\n" +
                "This is explicitly typed plain US-ASCII HTML text";

            Message message = new Message(Encoding.ASCII.GetBytes(rfcExample));

            MessagePart part = message.FindFirstMessagePartWithMediaType("text/html");

            Assert.NotNull(part);
            Assert.AreEqual("text/html", part.ContentType.MediaType);
            Assert.AreEqual("us-ascii", part.ContentType.CharSet);
            Assert.AreEqual(Encoding.ASCII, part.BodyEncoding);
            Assert.AreEqual("This is explicitly typed plain US-ASCII HTML text", part.GetBodyAsText());
        }
开发者ID:bitspill,项目名称:Gridcoin-master,代码行数:17,代码来源:MessageTest.cs

示例5: TestGetFirstMessageWithMediaTypeMultiPartFindMultiPartMediaTypeWithNestedMultiPart

        public void TestGetFirstMessageWithMediaTypeMultiPartFindMultiPartMediaTypeWithNestedMultiPart()
        {
            const string rfcExample =
                "From: Nathaniel Borenstein <[email protected]>\r\n" +
                "To: Ned Freed <[email protected]>\r\n" +
                "Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)\r\n" +
                "Subject: Sample message\r\n" +
                "MIME-Version: 1.0\r\n" +
                "Content-type: multipart/mixed; boundary=\"simple boundary\"\r\n" +
                "\r\n" +
                "--simple boundary\r\n" +
                "Content-type: multipart/mixed; boundary=\"anotherBoundary\"\r\n" +
                "\r\n" +
                "--anotherBoundary\r\n" +
                "\r\n" +
                "TEXT\r\n" +
                "--anotherBoundary\r\n" +
                "\r\n" +
                "MORE TEXT\r\n" +
                "--anotherBoundary--\r\n" +
                "--simple boundary\r\n" +
                "Content-type: text/html; charset=ISO-8859-1\r\n" +
                "\r\n" +
                "HTML\r\n" +
                "--simple boundary--";

            Message message = new Message(Encoding.ASCII.GetBytes(rfcExample));

            MessagePart part = message.FindFirstMessagePartWithMediaType("multipart/mixed");

            Assert.NotNull(part);
            Assert.IsTrue(part.IsMultiPart);
            Assert.AreEqual("simple boundary", part.ContentType.Boundary);
        }
开发者ID:bitspill,项目名称:Gridcoin-master,代码行数:34,代码来源:MessageTest.cs


注:本文中的OpenPop.Mime.Message.FindFirstMessagePartWithMediaType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。