Ejemplo n.º 1
0
        public MailListDetail GetMessageList(IEnumerable <Message> mailListDetail)
        {
            MailListDetail mailList = new MailListDetail();
            List <AttachmentProperties> attachmentList;
            List <MailCategories>       mailCategoriesList;
            List <MailListDetailItems>  items = new List <MailListDetailItems>();

            if (mailListDetail != null)
            {
                foreach (Message message in mailListDetail)
                {
                    attachmentList     = new List <AttachmentProperties>();
                    mailCategoriesList = new List <MailCategories>();
                    if (message.Attachments != null)//message.Attachments.Count != 0 &&
                    {
                        foreach (var item in message.Attachments.CurrentPage.ToList())
                        {
                            attachmentList.Add(new AttachmentProperties
                            {
                                AttachmentName = item.Name,
                                AttachmentSize = item.Size,
                                AttachmentType = item.ODataType,
                                AttachmentId   = item.Id
                            });
                        }
                    }
                    if (message.Categories != null)
                    {
                        foreach (var item in message.Categories.ToList())
                        {
                            mailCategoriesList.Add(new MailCategories
                            {
                                CategoryName = item
                            });
                        }
                    }


                    items.Add(new MailListDetailItems
                    {
                        EmailID    = message.From.EmailAddress.Address,
                        Display    = message.Subject,
                        Id         = message.Id,
                        Message    = message.BodyPreview,
                        Properties = attachmentList,
                        Categories = mailCategoriesList
                    });
                }
                mailList.Items = items;
            }
            return(mailList);
        }
Ejemplo n.º 2
0
 public PartialViewResult OpenSharedMailbox(string sharedMailId)
 {
     try
     {
         MailListDetail mailList       = new MailListDetail();
         var            mailListDetail = GraphHelper.OpenSharedMailbox(sharedMailId);
         mailList = GetMessageList(mailListDetail.Result);
         return(PartialView("MailBoxView", mailList.Items.ToList()));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        // GET: Mail
        public async Task <ActionResult> Index()
        {
            MailListDetail mailList = new MailListDetail();
            List <AttachmentProperties> attachmentList;
            List <MailListDetailItems>  items = new List <MailListDetailItems>();
            var mailListDetail = await GraphHelper.GetEventsAsync();

            if (mailListDetail != null)
            {
                foreach (Message message in mailListDetail)
                {
                    attachmentList = new List <AttachmentProperties>();
                    if (message.Attachments.Count != 0)
                    {
                        foreach (var item in message.Attachments.CurrentPage.ToList())
                        {
                            attachmentList.Add(new AttachmentProperties
                            {
                                AttachmentName = item.Name,
                                AttachmentSize = item.Size,
                                AttachmentType = item.ODataType,
                                AttachmentId   = item.Id
                            });
                        }
                    }
                    items.Add(new MailListDetailItems
                    {
                        EmailID    = message.From.EmailAddress.Address,
                        Display    = message.Subject,
                        Id         = message.Id,
                        Message    = message.BodyPreview,
                        Properties = attachmentList
                    });
                }
                mailList.Items = items;
            }

            return(View(mailList.Items.ToList()));
        }
Ejemplo n.º 4
0
        public async Task <JsonResult> MailInboxSearch(string sharedMailId)
        {
            MailListDetail mailList       = new MailListDetail();
            var            mailListDetail = (dynamic)null;

            if (!string.IsNullOrEmpty(sharedMailId))
            {
                mailListDetail = await GraphHelper.OpenSharedMailbox(sharedMailId);
            }
            else
            {
                mailListDetail = await GraphHelper.GetEventsAsync();
            }

            mailList = GetMessageList(mailListDetail);

            return(Json(new
            {
                view = RenderRazorViewToString(ControllerContext, "MailboxView", mailList.Items.ToList()),
                isValid = true,
                itemsCount = mailList.Items.ToList()
            }, JsonRequestBehavior.AllowGet));
        }