当前位置: 首页>>代码示例>>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;未经允许,请勿转载。