當前位置: 首頁>>代碼示例>>C#>>正文


C# Attachment.SetBody方法代碼示例

本文整理匯總了C#中Attachment.SetBody方法的典型用法代碼示例。如果您正苦於以下問題:C# Attachment.SetBody方法的具體用法?C# Attachment.SetBody怎麽用?C# Attachment.SetBody使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Attachment的用法示例。


在下文中一共展示了Attachment.SetBody方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ParseMime

        private static void ParseMime(Stream reader, string boundary, ref int maxLength, ICollection<Attachment> attachments, Encoding encoding, char? termChar)
        {
            var maxLengthSpecified = maxLength > 0;
            string data,
                bounderInner = "--" + boundary,
                bounderOuter = bounderInner + "--";

            do {
                data = reader.ReadLine(ref maxLength, encoding, termChar);
            } while (data != null && !data.StartsWith(bounderInner));

            while (data != null && !data.StartsWith(bounderOuter) && !(maxLengthSpecified && maxLength == 0)) {
                data = reader.ReadLine(ref maxLength, encoding, termChar);
                var a = new Attachment { Encoding = encoding };

                var part = new StringBuilder();
                // read part header
                while (!data.StartsWith(bounderInner) && data != string.Empty && !(maxLengthSpecified && maxLength == 0)) {
                    part.AppendLine(data);
                    data = reader.ReadLine(ref maxLength, encoding, termChar);
                }
                a.RawHeaders = part.ToString();
                // header body

                // check for nested part
                var nestedboundary = a.Headers.GetBoundary();
                if (!string.IsNullOrEmpty(nestedboundary)) {
                    ParseMime(reader, nestedboundary, ref maxLength, attachments, encoding, termChar);
                } else {
                    data = reader.ReadLine(ref maxLength, a.Encoding, termChar);
                    var body = new StringBuilder();
                    while (!data.StartsWith(bounderInner) && !(maxLengthSpecified && maxLength == 0)) {
                        body.AppendLine(data);
                        data = reader.ReadLine(ref maxLength, a.Encoding, termChar);
                    }
                    a.SetBody(body.ToString());
                    attachments.Add(a);
                }
            }
        }
開發者ID:yodanielo,項目名稱:aenetmail,代碼行數:40,代碼來源:MailMessage.cs

示例2: ParseMime

        private void ParseMime(TextReader reader, string boundary)
        {
            string data,
            bounderInner = "--" + boundary,
            bounderOuter = bounderInner + "--";

              do {
            data = reader.ReadLine();
              } while (data != null && !data.StartsWith(bounderInner));

              while (data != null && !data.StartsWith(bounderOuter)) {
            data = reader.ReadLine();
            var a = new Attachment();

            var part = new StringBuilder();
            // read part header
            while (!data.StartsWith(bounderInner) && data != string.Empty) {
              part.AppendLine(data);
              data = reader.ReadLine();
            }
            a.RawHeaders = part.ToString();
            // header body

            data = reader.ReadLine();
            var body = new StringBuilder();
            while (data != null && !data.StartsWith(bounderInner)) {
              body.AppendLine(data);
              data = reader.ReadLine();
            }
            // check for nested part
            string nestedboundary = a.Headers.GetBoundary();
            if (!string.IsNullOrEmpty(nestedboundary)) {
              using (var nestedReader = new System.IO.StringReader(body.ToString()))
            ParseMime(nestedReader, nestedboundary);

            } else { // nested
              a.SetBody(body.ToString());
              Attachments.Add(a);
            }
              }
        }
開發者ID:netngn,項目名稱:MailDeluxe,代碼行數:41,代碼來源:MailMessage.cs

示例3: ParseMime

        private void ParseMime(Stream reader, string boundary, int maxLength)
        {
            var maxLengthSpecified = maxLength > 0;
              string data,
            bounderInner = "--" + boundary,
            bounderOuter = bounderInner + "--";

              do {
            data = reader.ReadLine(ref maxLength, Encoding);
              } while (data != null && !data.StartsWith(bounderInner));

              while (data != null && !data.StartsWith(bounderOuter) && (maxLength > 0 || !maxLengthSpecified)) {
            data = reader.ReadLine(ref maxLength, Encoding);
            var a = new Attachment { Encoding = Encoding };

            var part = new StringBuilder();
            // read part header
            while (!data.StartsWith(bounderInner) && data != string.Empty) {
              part.AppendLine(data);
              data = reader.ReadLine(ref maxLength, Encoding);
            }
            a.RawHeaders = part.ToString();
            // header body

            data = reader.ReadLine(ref maxLength, Encoding);
            var body = new StringBuilder();
            while (data != string.Empty && !data.StartsWith(bounderInner)) {
              body.AppendLine(data);
              data = reader.ReadLine(ref maxLength, Encoding);
            }
            // check for nested part
            string nestedboundary = a.Headers.GetBoundary();
            if (!string.IsNullOrEmpty(nestedboundary)) {
              ParseMime(body.ToString(), nestedboundary);

            } else { // nested
              a.SetBody(body.ToString());
              (a.IsAttachment ? Attachments : AlternateViews).Add(a);
            }
              }

              if (maxLength > 0)
            data = reader.ReadToEnd(maxLength, Encoding);
        }
開發者ID:hugoham,項目名稱:aenetmail,代碼行數:44,代碼來源:MailMessage.cs


注:本文中的Attachment.SetBody方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。