krishnaveni
Well-Known Member
I have to develop one android example.
More than one item detail is send to mail from my android application.
Here i have to run the app means the latest added product detail alone send to mail.but i have to send the all added product detail is send to email.How can i do.please help me.whats wrong in my code.please check the code and give me solution for these.
I have used below code:
More than one item detail is send to mail from my android application.
Here i have to run the app means the latest added product detail alone send to mail.but i have to send the all added product detail is send to email.How can i do.please help me.whats wrong in my code.please check the code and give me solution for these.
I have used below code:
HTML:
public class InvoiceOrder extends Activity {
String mGrandTotal;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.invoice);
ListView mLstView1 = (ListView) findViewById(R.id.listView1);
CustomerAdapter mViewCartAdpt = new CustomerAdapter(
InvoiceOrder.this);
mLstView1.setAdapter(mViewCartAdpt);
Button login = (Button) findViewById(R.id.mBtnSubmit);
login.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
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 = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("krishnaveniv96@gmail.com","xxxxxx");
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("krishnaveniv96@gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("mercy.krishnaveni@gmail.com"));
message.setSubject("Testing Subject");
StringBuilder sb = new StringBuilder();
// message.setContent("This is your product name : "+
// "Hi Krishna" +"<br></br>This is your price : "+ "Hi veni", "text/html; charset=utf-8");
for (int i = 0; i < Constants.mItem_Detail
.size(); i++) {
String title = Constants.mItem_Detail
.get(i).get(
SingleMenuItem.KEY_PNAME);
String qty = Constants.mItem_Detail.get(i)
.get(SingleMenuItem.KEY_QTY);
String cost = Constants.mItem_Detail.get(i)
.get(SingleMenuItem.KEY_PRICE);
String total = Constants.mItem_Detail
.get(i).get(
SingleMenuItem.KEY_TOTAL);
message.setContent("<tr>" + "<td>" + title
+ "</td><td>" + qty + " * " + cost
+ "</td>" + " = <td>" + total
+ " " + "</td></tr>", "text/html; charset=utf-8");
}
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
});