public MessageBox[] GetAttachment(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.MessageId = objInput.MessageId;
                obj.Pin = System.Configuration.ConfigurationManager.AppSettings[objInput.Pin].ToString();
                objcol = objbll.GetAttachmentByMesageId(obj);
                if (objcol.Count() > 0)
                {
                    var objBox = new MessageBox[objcol.Count()];
                    for (int i = 0; i < objcol.Count(); i++)
                    {
                        MessageBox objR = new MessageBox();
                        if (objcol[i].Attachment != null && objcol[i].Attachment.Length > 0)
                        {
                            string[] filenames = objcol[i].Attachment.Split(',');
                            string[] filecont = new string[1];
                            string[] fileext = new string[1];
                            for (int icnt = 0; icnt <= filenames.GetUpperBound(0); icnt++)
                            {
                                if (icnt == objInput.AttachmentIndex)
                                {
                                    byte[] filecontent = File.ReadAllBytes(filenames[icnt]);
                                    FileInfo fi = new FileInfo(filenames[icnt]);
                                    filecont[0] = Convert.ToBase64String(filecontent);
                                    fileext[0] = fi.Name.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries)[1];
                                    objR.Attachment = filecont;
                                    objR.AttachmentExtension = fileext;
                                    break;
                                }

                            }

                        }
                        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;
            }
        }