public MessageBox[] MyMessages(Stream message)
        {
            MessageBox objInput = JSonHelper.JsonDeserialize<MessageBox>(new StreamReader(message).ReadToEnd());
            if (System.Configuration.ConfigurationManager.AppSettings[objInput.Pin] == null)
            {
                var objArray = new MessageBox[1];
                MessageBox obj2 = new MessageBox();
                obj2.ErrorMessage = "Invalid PIN";
                obj2.MessengerMessage = "Invalid PIN";
                objArray[0] = obj2;
                return objArray;
            }
            if (objInput.Pin != null && objInput.Pin.Length > 0)
            {
                var objArray = new MessageBox[1];
                MessageBox obj2 = new MessageBox();
                obj2.ErrorMessage = "No messages found";
                obj2.MessengerMessage = "No messages found";
                List<MessageInfo> objcol = new List<MessageInfo>();
                MessageInfo obj = new MessageInfo();
                MessageBLL objbll = new MessageBLL();
                obj.ToId = objInput.ToId;
                obj.ToType = objInput.userType;
                obj.Getattachment = objInput.GetAttachment;
                obj.Pin = System.Configuration.ConfigurationManager.AppSettings[objInput.Pin].ToString();
                objcol = objbll.BindInboxMessages(obj);
                if (objcol.Count() > 0)
                {
                    var objBox = new MessageBox[objcol.Count()];
                    for (int i = 0; i < objcol.Count(); i++)
                    {
                        MessageBox objR = new MessageBox();
                        objR.MessageComposeId = objcol[i].MessageComposeId;
                        objR.FromId = objcol[i].FromId;
                        objR.ToId = objcol[i].ToId;
                        objR.FromEmailId = objcol[i].FromEmailId;
                        objR.ToEmailId = objcol[i].ToEmailId;
                        objR.MessageId = objcol[i].MessageId;
                        objR.Subject = objcol[i].Subject;
                        objR.Message = objcol[i].Message;
                        if (objcol[i].Attachment != null && objcol[i].Attachment.Length > 0)
                        {
                            ////byte[] filecontent = File.ReadAllBytes(objcol[i].Attachment);
                            //FileInfo fi = new FileInfo(objcol[i].Attachment);
                            ////objR.Attachment = Convert.ToBase64String(filecontent);
                            //string extension = fi.Name.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries)[1];
                            //objR.AttachmentExtension = extension.Split(',');


                            string[] files = objcol[i].Attachment.Split(',');
                            string[] filextensions = new string[files.Count()];

                            for (int icnt = 0; icnt <= files.GetUpperBound(0); icnt++)
                            {
                                string[] filecomps = files[icnt].Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                                if (filecomps.GetUpperBound(0) >= 1)
                                {
                                    filextensions[icnt] = filecomps[1];
                                }
                            }


                            objR.AttachmentExtension = filextensions;
                        }
                        objR.LocationCoordinates = objcol[i].LocationCoordinates;
                        objR.FromType = objcol[i].FromType;
                        objR.ToType = objcol[i].ToType;
                        objR.Status = objcol[i].Status;
                        objR.ProcessDate = objcol[i].ProcessDate;
                        objR.FromName = objcol[i].FromName;
                        objR.userType = objcol[i].userType;
                        objR.physicianId = objcol[i].physicianId;
                        objR.MessageRepliedTo = objcol[i].MessageRepliedTo;
                        objR.IsMessageRead = objcol[i].IsMessageRead;
                        objR.MessageSignatureId = objcol[i].MessageSignatureId;
                        objR.MessageSignatureName = objcol[i].MessageSignatureName;
                        objR.MessageSignatureOffcName = objcol[i].MessageSignatureOffcName;
                        objBox[i] = objR;
                    }
                    return objBox;
                }
                objArray[0] = obj2;
                return objArray;
            }
            else
            {
                var objArray = new MessageBox[1];
                MessageBox obj2 = new MessageBox();
                obj2.ErrorMessage = "PIN is a required field";
                obj2.MessengerMessage = "Pin is a required field";
                objArray[0] = obj2;
                return objArray;
            }
        }