try { MailAddress fromemail = new MailAddress(inputEmail); } catch(Exception ex) { string str = ex.Message; }