2012-02-26 27 views
0

嗨iam试图发送邮件,而不按发送按钮在默认布局。如何发送邮件,而不按发送按钮默认布局

我尝试这个代码

意图emailIntent =新意图(Intent.ACTION_SEND); emailIntent.setType(“text/plain”);

String[] recipients = new String[]{"[email protected]", "",}; 
    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...")); 

    } 

我想在选择Gmail时自动选择发送按钮。 请帮助我。

+0

我想这是不可能的编程机器人......用户的默认电子邮件应用程序中按下发送键必须点击发送按钮....你可以采取替代为此使用JavaMail Api发送电子邮件没有用户按发送按钮...检查此链接.... http://stackoverflow.com/questions/2020088/sending-email-in-android - 使用 - JavaMail的-API不-使用最默认的Android-A – Kri 2012-02-26 17:58:44

回答

0

我们有类似的情况,我们想在没有用户点击发送按钮的情况下调用电子邮件应用程序。我们确实试图找出方法,然后采取解决方案,我们没有调用电子邮件应用程序的活动。我们改为调用webservice API和用于发送邮件的服务器。

0

入住这Sending Email in Android using JavaMail API without using the default/built-in app 您更改MailSenderActivity.class如下

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

      try { 
       GMailSender sender = new GMailSender("[email protected]", "password"); 
       sender.sendMail("This is Subject", 
         "This is Body",  
         "[email protected]","receivermail.com"); 
      } catch (Exception e) { 
       Log.e("SendMail", e.getMessage(), e); 
      } 
     } 
相关问题