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


C# Message.FindAllTextVersions方法代码示例

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


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

示例1: FindPlainTextInMessage

 private string FindPlainTextInMessage(Message message)
 {
     OpenPop.Mime.Header.MessageHeader msgheader = message.Headers;
     string sender = msgheader.From.Address;
     string LinkExtracted = "";
     if (sender == cSender)
     {
         List<MessagePart> list = message.FindAllTextVersions();
         string str = "";
         foreach (MessagePart part in list)
         {
             if (part != null)
             {
                 try
                 {
                     //string pattern = @"http://www.gutefrage.net/registrierungsbestaetigung.*(?=\042)";  linkpattern
                     //part.Save(new FileInfo("temp"));
                     //string str2 = File.ReadAllText("temp");
                     string str2 = part.GetBodyAsText();
                     int startIndex = 0;
                     int num2 = 0;
                     startIndex = str2.IndexOf(linkpattern, startIndex);
                     while (startIndex != -1)
                     {
                         startIndex = startIndex + ShiftBy;
                         char[] anyOf = new char[] { ' ', '"', '>', '<', '\r', '\n', '\\', ')' };
                         num2 = str2.IndexOfAny(anyOf, startIndex);
                         string str3 = str2.Substring(startIndex, num2 - startIndex);
                         if (str == str3)
                         {
                             startIndex = str2.IndexOf(linkpattern, num2);
                         }
                         else
                         {
                             // File.AppendAllText("links.txt", str3 + "\r\n");
                             LinkExtracted = str3;
                             str = str3;
                             startIndex = str2.IndexOf(linkpattern, num2);
                         }
                     }
                     return LinkExtracted;
                 }
                 catch (Exception)
                 {
                     // Console.WriteLine("Pizdets!");
                     return null;
                 }
             }
         }
     }
     if (LinkExtracted != "")
     {
         return LinkExtracted;
     }
     else
     {
         return null;
     }
 }
开发者ID:tablesmit,项目名称:iMacrosTest-CSharp,代码行数:59,代码来源:HotmailPOP.cs

示例2: SaveMail

        private static void SaveMail(int i, Message message)
        {
            MessagePart plainHtmlPart = message.FindFirstHtmlVersion();
            MessagePart plainTextPart = message.FindFirstPlainTextVersion();
            string textMail = null;
            if (plainHtmlPart == null && plainTextPart != null)
            {
                textMail = plainTextPart.GetBodyAsText();
            }
            else if (plainHtmlPart == null && plainTextPart == null)
            {
                List<MessagePart> textVersions = message.FindAllTextVersions();
                if (textVersions.Count >= 1)
                    textMail = textVersions[0].GetBodyAsText();
            }
            else if (plainHtmlPart != null)
            {
                textMail = plainHtmlPart.GetBodyAsText();
            }

            string xamlMail = HTMLConverter.HtmlToXamlConverter.ConvertHtmlToXaml(textMail, true);
            StringReader sr = new StringReader(xamlMail);
            XmlReader xr = XmlReader.Create(sr);
            FlowDocument fdMail = (FlowDocument)XamlReader.Load(xr);
            FlowDocument fd = new FlowDocument();
            DateTime dateMail = Convert.ToDateTime(message.Headers.Date);
            BLL.DiaryBLL dbll = new BLL.DiaryBLL();

            fd = dbll.GetDoc(dateMail.Date.ToString());
            fd = CommonHelper.MergeFlowDocument(fd, fdMail);
            dbll.Save(fd, dateMail.Date.ToString());
        }
开发者ID:QingWei-Li,项目名称:MyLife,代码行数:32,代码来源:MailHelper.cs

示例3: TestComplexMultiPartMessage

        public void TestComplexMultiPartMessage()
        {
            const string multiPartMessage =
                "MIME-Version: 1.0\r\n" +
                "From: Nathaniel Borenstein <[email protected]>\r\n" +
                "To: Ned Freed <[email protected]>\r\n" +
                "Date: Fri, 07 Oct 1994 16:15:05 -0700 (PDT)\r\n" +
                "Subject: A multipart example\r\n" +
                "Content-Type: multipart/mixed;\r\n" +
                "\t\t\t\t\t\t boundary=unique-boundary-1\r\n" +
                "\r\n" +
                "This is the preamble area of a multipart message.\r\n" +
                "Mail readers that understand multipart format\r\n" +
                "should ignore this preamble.\r\n" +
                "\r\n" +
                "If you are reading this text, you might want to\r\n" +
                "consider changing to a mail reader that understands\r\n" +
                "how to properly display multipart messages.\r\n" +
                "\r\n" +
                "--unique-boundary-1\r\n" +
                "\r\n" +
                " ... Some text appears here ...\r\n" +
                "--unique-boundary-1\r\n" +
                "Content-type: text/plain; charset=US-ASCII\r\n" +
                "\r\n" +
                "This could have been part of the previous part, but\r\n" +
                "illustrates explicit versus implicit typing of body\r\n" +
                "parts.\r\n" +
                "--unique-boundary-1\r\n" +
                "Content-Type: multipart/parallel; boundary=unique-boundary-2\r\n" +
                "\r\n" +
                "--unique-boundary-2\r\n" +
                "Content-Type: audio/basic\r\n" +
                "Content-Transfer-Encoding: base64\r\n" +
                "\r\n" +
                "dGVzdCBhdWRpbw==\r\n" + // "test audio" in base64
                "--unique-boundary-2\r\n" +
                "Content-Type: image/jpeg\r\n" +
                "Content-Transfer-Encoding: base64\r\n" +
                "\r\n" +
                "dGVzdCBpbWFnZQ==\r\n" + // "test image" in base64
                "--unique-boundary-2--\r\n" +
                "\r\n" +
                "--unique-boundary-1\r\n" +
                "Content-type: text/enriched\r\n" +
                "\r\n" +
                "This is <bold><italic>enriched.</italic></bold>\r\n" +
                "<smaller>as defined in RFC 1896</smaller>\r\n" +
                "\r\n" +
                "Isn\'t it\r\n" +
                "<bigger><bigger>cool?</bigger></bigger>\r\n" +
                "--unique-boundary-1\r\n" +
                "Content-Type: message/rfc822\r\n" +
                "\r\n" +
                "From: Test <[email protected]>\r\n" +
                "To: Test <[email protected]>\r\n" +
                "Subject: Test subject\r\n" +
                "Content-Type: Text/plain; charset=ISO-8859-1\r\n" +
                "Content-Transfer-Encoding: Quoted-printable\r\n" +
                "\r\n" +
                "... Additional text in ISO-8859-1 goes here ... 3 + 5 =3D 8\r\n" +
                "--unique-boundary-1--";

            // No special characters used - we can use ASCII to get the bytes
            Message message = new Message(Encoding.ASCII.GetBytes(multiPartMessage));

            Assert.AreEqual("1.0", message.Headers.MimeVersion);

            // From
            Assert.AreEqual("Nathaniel Borenstein", message.Headers.From.DisplayName);
            Assert.AreEqual("[email protected]", message.Headers.From.Address);

            // To
            Assert.NotNull(message.Headers.To);
            Assert.AreEqual(1, message.Headers.To.Count);
            Assert.AreEqual("Ned Freed", message.Headers.To[0].DisplayName);
            Assert.AreEqual("[email protected]", message.Headers.To[0].Address);

            // Date
            Assert.AreEqual("Fri, 07 Oct 1994 16:15:05 -0700 (PDT)", message.Headers.Date);
            // -0700 is the same as adding 7 hours in the UTC DateTime
            Assert.AreEqual(new DateTime(1994, 10, 7, 23, 15, 05, DateTimeKind.Utc), message.Headers.DateSent);

            // Subject
            Assert.AreEqual("A multipart example", message.Headers.Subject);

            MessagePart part1 = message.MessagePart;
            Assert.AreEqual("multipart/mixed", part1.ContentType.MediaType);
            Assert.IsTrue(part1.IsMultiPart);
            Assert.NotNull(part1.MessageParts);
            Assert.IsNull(part1.Body);

            // There is a total of 5 multiparts in the first message (unique-boundary-1)
            Assert.AreEqual(5, part1.MessageParts.Count);

            // Fetch out the parts, which are checked against later
            System.Collections.Generic.List<MessagePart> attachments = message.FindAllAttachments();
            System.Collections.Generic.List<MessagePart> textVersions = message.FindAllTextVersions();

            // We are now going one level deeper into the message tree
//.........这里部分代码省略.........
开发者ID:bitspill,项目名称:Gridcoin-master,代码行数:101,代码来源:MessageTest.cs

示例4: TestContentTypeWithLargeCharactersCanStillBeFound

        public void TestContentTypeWithLargeCharactersCanStillBeFound()
        {
            const string messagePartContent =
                "Content-Type: TEXT/PLAIN\r\n" +
                "\r\n" + // End of message headers
                "foo";

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

            // Cna be found
            MessagePart textHtml = message.FindFirstPlainTextVersion();
            Assert.NotNull(textHtml);

            Assert.AreEqual("foo", textHtml.GetBodyAsText());

            // Can still be found
            System.Collections.Generic.List<MessagePart> messageParts = message.FindAllTextVersions();
            Assert.IsNotEmpty(messageParts);
            Assert.AreEqual(1, messageParts.Count);
            Assert.AreEqual(textHtml, messageParts[0]);
        }
开发者ID:bitspill,项目名称:Gridcoin-master,代码行数:21,代码来源:MessageTest.cs


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