Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • how to send email via intent

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 65
    Comment on it

    Here is a way by which you can send the email via android-intent.


    The below code opens a dialog showing email related apps e.g. Gmail, Yahoo Mail etc. if installed in your device.
    In case your device is not installed with mailing applications then it will go to catch block and show the appropriate message.

    String subject="subject_title";
    String mailBody="Hello, This is the text of my mail"
    String[] receipentList ={"receiver1@gmail.com", "receiver2@yahoo.com"};
    String[] ccReceipentList ={"receiver3@gmail.com", "receiver4@yahoo.com"};
    
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("text/plain");
    i.putExtra(Intent.EXTRA_EMAIL  , receipentList);
    i.putExtra(Intent.EXTRA_CC, ccReceipentList);
    i.putExtra(Intent.EXTRA_SUBJECT, subject);
    i.putExtra(Intent.EXTRA_TEXT  , mailBody);
    try
     {
        startActivity(Intent.createChooser(i, "Send mail..."));
     } 
    catch (android.content.ActivityNotFoundException ex) 
     {
       Toast.makeText(MyActivity.this, "No email clients available.", Toast.LENGTH_SHORT).show();
     }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: