0

Hi iam trying to send mail without pressing send button in default layout.

I tries this code

Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("text/plain");

    String[] recipients = new String[]{"yourmail@email.com", "",};
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Sample mail");
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is a sample mail..");
    try {
        startActivity(Intent.createChooser(emailIntent, "Send mail..."));

    }

i want to select the send button automatically when i select the gmail. pls help me.

Thamizh
  • 1
  • 3
  • i suppose it is not possible to press the send button programmatically of default email application of android...user have to click on the send button....you can take alternative for this using JavaMail Api to send email without user pressing send button...check this link....http://stackoverflow.com/questions/2020088/sending-email-in-android-using-javamail-api-without-using-the-default-android-a – Kri Feb 26 '12 at 17:58

2 Answers2

0

Check this Sending Email in Android using JavaMail API without using the default/built-in app You change MailSenderActivity.class as below

     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         // setContentView(R.layout.main);

            try {   
                GMailSender sender = new GMailSender("urmail@gmail.com", "password");
                sender.sendMail("This is Subject",   
                        "This is Body",     
                        "urmail@gmail.com","receivermail.com");   
            } catch (Exception e) {   
                Log.e("SendMail", e.getMessage(), e); 
            }  
       }
Community
  • 1
  • 1
Swathi
  • 142
  • 1
  • 3
  • 6
0

We had a similar situation where we wanted to call Email application without user clicking on Send button. We did try to find out the way and then resorted to solution where we didn't call the Email application's Activity. We instead called a webservice API and the server used to send the mail.