protected virtual StorableMailMessage CopyToStorableMailMessage(IMailMessage other)
        {
            var storeMessage = new StorableMailMessage
            {
                CreationDate  = DateTime.Now,
                NextRetryDate = DateTime.Now,
                From          = other.From,
                To            = other.To,
                Cc            = other.Cc,
                Bcc           = other.Bcc,
                Body          = other.Body,
                IsHtmlBody    = other.IsHtmlBody,
                ReplyTo       = other.ReplyTo,
                Subject       = other.Subject
            };

            foreach (var att in other.Attachments)
            {
                using (var memoryStream = new MemoryStream())
                {
                    att.GetContentStream().CopyTo(memoryStream);
                    storeMessage.Add(new StorableMailAttachment(storeMessage)
                    {
                        ContentType = att.GetContentType(), Content = memoryStream.ToArray()
                    });
                }
            }

            return(storeMessage);
        }
Пример #2
0
 public StorableMailMessage Insert(StorableMailMessage msg)
 {
     lock (store)
     {
         msg.Id = ++nextId;
         store.Add(msg);
         return(msg);
     }
 }
Пример #3
0
 public void Delete(StorableMailMessage msg)
 {
     lock (store)
     {
         var pos = store.IndexOf(msg);
         if (pos >= 0)
         {
             store.RemoveAt(pos);
         }
     }
 }