private object ToRightDataType(string value, SearchDataType type) { if (string.IsNullOrEmpty(value)) { return(null); } if (type == SearchDataType.Text) { return(value); } else if (type == SearchDataType.Number) { int intvalue = 0; if (int.TryParse(value, out intvalue)) { return(intvalue); } else { return(null); } } else if (type == SearchDataType.Date) { return(ImapHelper.ParseRfc2822Time(value)); } return(null); }