java - Illegal character In email address after removing whitespaces -


i taking in email address via edittext. got error saying address contained whitespaces, no problem. implemented address.removeall("\\s" , ""); , getting error

  • 04-16 09:37:43.009: w/system.err(1632): javax.mail.internet.addressexception: illegal character in local name in string ``606#7f080011app:id/enteremail}''

here code capturing email , converting string.

      edittext e = (edittext) findviewbyid(r.id.enteremail);        string = e.tostring().replaceall("\\s", ""); 

on line use address , error:

msg.setrecipient(mimemessage.recipienttype.to, new internetaddress(to)); 

i have done research trying find if parsing issue or causing found nothing. know why getting error? in advance.

that's because you're converting edittext string instead of getting text , doing replaceall() on it.

simply replace this:

string = e.tostring().replaceall("\\s", ""); 

with this:

string = e.gettext().tostring().replaceall("\\s", ""); 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -