android - Send a mail with an app -
i want send mail, after button pressed app. app nothing, wrong code?
public void onclick(view v) { properties props = new properties(); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.socketfactory.port", "465"); props.put("mail.smtp.socketfactory.class", "javax.net.ssl.sslsocketfactory"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", "465"); session = session.getdefaultinstance(props, new authenticator() { protected passwordauthentication getpasswordauthentication() { return new passwordauthentication("test@gmail.com", "14lalal"); } }); pdialog = progressdialog.show(mainactivity.sactivity , "", "sending mail...", true); retreivefeedtask task = new retreivefeedtask(); task.execute(); } class retreivefeedtask extends asynctask<string, void, string> { @override protected string doinbackground(string... params) { try{ message message = new mimemessage(session); message.setfrom(new internetaddress("test@gmail.com")); message.setrecipients(message.recipienttype.to, internetaddress.parse("test2@gmail.com")); message.setsubject("lala"); message.settext("gldf"); transport.send(message); } catch(messagingexception e) { e.printstacktrace(); } catch(exception e) { e.printstacktrace(); } return null; } @override protected void onpostexecute(string result) { pdialog.dismiss(); toast.maketext(mcontext, "message sent", toast.length_long).show(); } } }
the alertdialog
displays correctly not receive mail.
Comments
Post a Comment