1. Check out our companion app, Forums for Android! Download from Google Play

send mail from my android listview use javamailapi

Discussion in 'Application Development' started by krishnaveni, Jan 3, 2013.

  1. krishnaveni

    krishnaveni Well-Known Member
    Thread Starter
    55

    Dec 16, 2011
    158
    0
    55
    chennai
    Hi.,


    I have to develop one android application. here i have to send mail automatically from my android application.so i have use javamailapi here.

    I have to send mail listview vlaues from my android application.

    These is my code:
    [HIGH]
    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("mroslinmary@gmail.com","ASDz78xc123");
    }
    });

    try {

    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress("krish.v@mercurygfyt.com"));
    message.setRecipients(Message.RecipientType.TO,
    InternetAddress.parse("demo@mercurygfyt.com"));
    message.setSubject("Testing Subject");
    message.setContent("This is your product name : "+
    "Hi Krishna", "How are you");
    Transport.send(message);

    System.out.println("Done");

    } catch (MessagingException e) {
    throw new RuntimeException(e);
    }
    }



    [/HIGH]Here i have to run the app means am getting the Hi Krishna How are is send successfully to demo@mercuryminds.com

    But i have to send listview .how can i set the listview to my message.setContent();field.please give me some ideas.
     

    Advertisement

Share This Page

Loading...