public ToFields[] GetToField(Stream message)
        {

            ToFields objInput = JSonHelper.JsonDeserialize<ToFields>(new StreamReader(message).ReadToEnd());
            if (System.Configuration.ConfigurationManager.AppSettings[objInput.Pin] == null)
            {
                var objArray1 = new ToFields[1];
                ToFields otoField = new ToFields();
                otoField.ToId = "0";
                otoField.Name = "";
                otoField.UserType = "0";
                otoField.MessengerMessage = "Invalid PIN";
                objArray1[0] = otoField;
                return objArray1;
            }
            if (objInput.Pin != null && objInput.Pin.Length > 0)
            {
                List<MessageInfo> objcol = new List<MessageInfo>();
                MessageInfo obj = new MessageInfo();
                MessageBLL objbll = new MessageBLL();
                obj.ToId = Convert.ToInt32(objInput.ToId);
                obj.userType = Convert.ToInt32(objInput.UserType);
                obj.Pin = System.Configuration.ConfigurationManager.AppSettings[objInput.Pin].ToString();
                objcol = objbll.GetToFieldAutopopup(obj, objInput.Name);
                var objArray = new ToFields[objcol.Count];
                var autoPopUpdata = new List<string>(objcol.Count);
                if (objcol.Count > 0)
                {

                    for (var i = 0; i < objcol.Count; i++)
                    {
                        //var elementAtOrDefault = objcol.ElementAtOrDefault(i);
                        //if (elementAtOrDefault != null)
                        //    autoPopUpdata.Add(string.Format("{0}-{1}-{2}", elementAtOrDefault.FromName,
                        //                                    elementAtOrDefault.ToId,
                        //                                    elementAtOrDefault.userType));

                        ToFields otoField = new ToFields();
                        MessageInfo msginfo = objcol[i];
                        otoField.ToId = msginfo.ToId.ToString();
                        otoField.Name = msginfo.FromName;
                        otoField.ToEmail = msginfo.ToEmailId;
                        otoField.UserType = msginfo.ToType.ToString();
                        objArray[i] = otoField;
                    }
                }
                return objArray;
            }
            else
            {
                var objArray1 = new ToFields[1];
                ToFields otoField = new ToFields();
                otoField.ToId = "0";
                otoField.Name = "";
                otoField.UserType = "0";
                otoField.MessengerMessage = "Pin is a required field";
                objArray1[0] = otoField;
                return objArray1;
            }
        }