Пример #1
0
        protected override ResourceInfo GetResourceInfo(WebDavTicket ticket)
        {
            ResourceInfo retVal = new ResourceInfo();
            EmailStorageAbsolutePath absPath = ticket.AbsolutePath as EmailStorageAbsolutePath;
            if(absPath == null)
                throw new ArgumentException("absPath");

            EMailMessageRow row = new EMailMessageRow(absPath.EmailMsgId);
            MemoryStream memStream = new MemoryStream(row.EmlMessage.Length);
            memStream.Write(row.EmlMessage, 0, row.EmlMessage.Length);
            memStream.Position = 0;

            Pop3Message message = new Pop3Message(memStream);
            int attachmentIndex = absPath.EmailAttachmentIndex;
            Mediachase.IBN.Business.EMail.EMailMessageInfo.AttachmentData entry =
                            EMailMessageInfo.GetAttachment(message.MimeEntries, ref attachmentIndex);

            if (entry != null)
            {

                retVal.AbsolutePath = ticket.ToString();
                retVal.Tag = entry;
                retVal.Name = entry.FileName;
                //Fix ET:26-11-2008 Solve trouble inconsistency Content-Type email attachment and file extension
                //try first get Content-Type by file extension
                retVal.ContentType = ContentTypeResolver.Resolve(Path.GetExtension(entry.FileName));
                if (String.IsNullOrEmpty(retVal.ContentType))
                {
                    //otherwise set ContentType as ContentType email attachment
                    retVal.ContentType = entry.ContentType;
                }
                retVal.ContentLength = entry.Data.Length;
                retVal.ParentName = "root";
                DateTime created = Database.DBCommon.GetLocalDate(Security.CurrentUser.TimeZoneId, row.Created);
                retVal.Created = created;
                retVal.Modified = created;
            }

            return retVal;
        }
Пример #2
0
 /// <summary>
 /// Gets the POP3 message.
 /// </summary>
 /// <param name="EMailMessageId">The E mail message id.</param>
 /// <returns></returns>
 public static Pop3Message GetPop3Message(int EMailMessageId)
 {
     EMailMessageRow row = new EMailMessageRow(EMailMessageId);
     return GetPop3Message(row.EmlMessage);
 }
Пример #3
0
        public static ArrayList Send(int IncidentId, int EMailMessageId)
        {
            EMailMessageRow row = new EMailMessageRow(EMailMessageId);

            return Send(IncidentId, EMailRouterPop3Box.Load(row.EMailRouterPop3BoxId), EMailMessage.GetPop3Message(row.EmlMessage));
        }
Пример #4
0
        /// <summary>
        /// Creates the specified message.
        /// </summary>
        /// <param name="EMailRouterPop3BoxId">The E mail router POP3 box id.</param>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        public static int Create(int EMailRouterPop3BoxId, Pop3Message message)
        {
            if (message == null)
                throw new ArgumentNullException("message");

            EMailMessageRow newRow = new EMailMessageRow();

            newRow.EMailRouterPop3BoxId = EMailRouterPop3BoxId;
            //newRow.Created = DateTime.UtcNow;
            newRow.From = EMailMessage.GetSenderEmail(message);

            //if (message.Sender != null)
            //    newRow.From = EMailMessage.ExtractFirstEmail(message.Sender.Email);
            //else
            //    newRow.From = EMailMessage.ExtractFirstEmail(message.From.Email);

            newRow.To = EMailMessage.ExtractFirstEmail(message.To);

            newRow.Subject = message.Subject == null ? string.Empty : message.Subject;

            newRow.EmlMessage = GetPop3MessageBytes(message);

            newRow.Update();

            return newRow.PrimaryKeyId;
        }