email - How to set E-Mail configuraion on android device programmatically -
i want create app on android , make config e-mail setting on android device programmatically when setting data server.
i have search around android code example can't find example , don't know start looking.
can 1 suggest should start looking?
thank you
update sorry unclear question.
i used method send email programmatically . can use this. you.
//send email boolean sendmail(string from,string to) { boolean issend=false; properties props = system.getproperties(); string host = "smtp.gmail.com"; props.put("mail.smtp.starttls.enable", "true"); //enable gmail props.put("mail.smtp.user", "abc@gmail.com"); props.put("mail.smtp.password", "abc"); props.put("mail.smtp.port", "587"); //gmail port address props.put("mail.smtp.auth", "true"); log.d("tag","props set"); session session = session.getdefaultinstance(props,null); log.d("tag","session set"); mimemessage message = new mimemessage(session); log.d("tag","message set"); try { message.setfrom(new internetaddress(from)); internetaddress add = new internetaddress(to); message.addrecipient(message.recipienttype.to, add); message.setsubject("hello"); message.settext("hello world"); transport transport = session.gettransport("smtp"); transport.connect(host,from, "hello world"); transport.sendmessage(message, message.getallrecipients()); transport.close(); issend=true; } catch (addressexception ae) { ae.printstacktrace(); issend=false; } catch (messagingexception me) { me.printstacktrace(); issend=false; } return issend; }
Comments
Post a Comment