Android的发送邮件 [英] Android send mail

查看:175
本文介绍了Android的发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下main.xml中我有一个EditText上,我的问题是如何的onclick发送邮件按钮如何发送邮件,其中为了解决是很难codeD总是..

  mail.setOnClickListener(        @覆盖
        公共无效的onClick(视图v){
       //如何sendmail来ADRESS someadress@xx.com oblibk发送邮件按钮    });     < LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android机器人:方向=垂直机器人:ID =@ + ID / linearLayout3的android:layout_width =FILL_PARENT机器人:layout_height =FILL_PARENT>
      < EditText上机器人:ID =@ + ID / editText2的android:layout_width =FILL_PARENT机器人:layout_height =WRAP_CONTENT>
         <&requestFocus的GT;< / requestFocus的>
      < /&的EditText GT;
      <按钮的android:文本=发送邮件机器人:ID =@ + ID /邮件的android:layout_width =WRAP_CONTENT机器人:layout_height =WRAP_CONTENT>< /按钮>
      <按钮的android:文本=返回机器人:ID =@ + ID / back2的android:layout_width =WRAP_CONTENT机器人:layout_height =WRAP_CONTENT>< /按钮>
   < / LinearLayout中>


解决方案

 最终意图emailIntent =新意图(android.content.Intent.ACTION_SEND);
emailIntent.setType(纯/文);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,新的String [] {youraddress@aaaaa.com});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,yourSubject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,yourBodyText);
context.startActivity(Intent.createChooser(意向,发送邮件...));

In the following main.xml i have a edittext,my question is how to onclick of send mail button how to send a mail where the To address is hardcoded always..

 mail.setOnClickListener(

        @Override
        public void onClick(View v) {
       //How to sendmail to adress someadress@xx.com oblibk of send mail button

    });

     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:id="@+id/linearLayout3" android:layout_width="fill_parent" android:layout_height="fill_parent">
      <EditText android:id="@+id/editText2" android:layout_width="fill_parent" android:layout_height="wrap_content">
         <requestFocus></requestFocus>
      </EditText>
      <Button android:text="Send Mail" android:id="@+id/mail" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
      <Button android:text="Back" android:id="@+id/back2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>


   </LinearLayout>

解决方案

 final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);     
emailIntent.setType("plain/text");     
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"youraddress@aaaaa.com"});     
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, yourSubject);     
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, yourBodyText);     
context.startActivity(Intent.createChooser(intent, "Send mail..."));

这篇关于Android的发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆