コード例 #1
0
 public InternetMailMessage(MimeMessage nativeMessage, string identifier) : this(nativeMessage.Headers)
 {
     Uid.Add(ValueFactory.Create(identifier));
     if (nativeMessage.Body is TextPart)
     {
         Texts.Add(new InternetMailText(nativeMessage.Body as TextPart));
     }
     else if (nativeMessage.Body is Multipart)
     {
         var body = nativeMessage.Body as Multipart;
         foreach (var part in body)
         {
             if (part is TextPart)
             {
                 var tpart = part as TextPart;
                 Texts.Add(new InternetMailText(tpart));
             }
             else if (part is MessageDeliveryStatus)
             {
                 // TODO: MessageDeliveryStatus
             }
             else if (part is MessagePart)
             {
                 // Письмо во вложении
                 // TODO: MessagePart
             }
             else
             {
                 // Console.Write("Unchecked type: ");
                 // Console.WriteLine(part.GetType());
             }
         }
     }
 }
コード例 #2
0
        public InternetMailMessage(MimeMessage nativeMessage, string identifier) : this(nativeMessage.Headers)
        {
            Uid.Add(ValueFactory.Create(identifier));
            if (nativeMessage.Body is TextPart)
            {
                Texts.Add(new InternetMailText(nativeMessage.Body as TextPart));
            }
            else if (nativeMessage.Body is Multipart)
            {
                var body = nativeMessage.Body as Multipart;
                foreach (var part in body)
                {
                    if (part is TextPart)
                    {
                        var tpart = part as TextPart;
                        Texts.Add(new InternetMailText(tpart));
                    }
                    else if (part is MessageDeliveryStatus)
                    {
                        // TODO: MessageDeliveryStatus
                    }
                    else if (part is MessagePart)
                    {
                        // Письмо во вложении
                        // TODO: MessagePart
                    }
                    else
                    {
                        // Console.Write("Unchecked type: ");
                        // Console.WriteLine(part.GetType());
                    }
                }
            }

            foreach (var attachment in nativeMessage.Attachments)
            {
                var part     = (MimePart)attachment;
                var fileName = part.FileName;
                var stream   = new MemoryStream();

                part.ContentObject.DecodeTo(stream);
                BinaryDataContext bin = new BinaryDataContext(stream.ToArray());
                Attachments.Add(bin, fileName);
            }
        }