简体   繁体   中英

How to send mail without pressing send button in default layout

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.

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); 
            }  
       }

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM