将textview内容和imageview发送到电子邮件

时间:2012-11-15 14:40:13

标签: java android email textview

我正在创建一个应用程序,当我按下按钮时将TextView内容发送给我的电子邮件,但我知道如何做到这一点,我需要帮助。

我需要发送电子邮件给tvFechaSi和ImageView发送电子邮件到wrfrewf@gmail.com(这是一封假电子邮件)

public class FormBotonSi extends Activity {

      private String SFecha; 
      private TextView tvFechaSi ;    
      private static final int CAMERA_REQUEST = 1888; 
      private ImageView imageView;


    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.formbotonsi);

        Bundle bundle=getIntent().getExtras();


        tvFechaSi=(TextView) findViewById(R.id.tvFechaSi);
        Fecha =bundle.getString("Fecha");
        tvFechaSi.setText(Fecha.toString()); 

        this.imageView = (ImageView)this.findViewById(R.id.imageView1);
        Button photoButton = (Button) this.findViewById(R.id.button1);


        Spinner sp = (Spinner) findViewById(R.id.spinner1);
        ArrayAdapter adapter = ArrayAdapter.createFromResource(
            this, R.array.tipoPrioridad, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        sp.setAdapter(adapter);   




        photoButton.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); 
                startActivityForResult(cameraIntent, CAMERA_REQUEST); 
            }
        });
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
        if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {  
            Bitmap photo = (Bitmap) data.getExtras().get("data"); 
            imageView.setImageBitmap(photo);
        }  
    } 

}

2 个答案:

答案 0 :(得分:2)

我认为此代码可以帮助您:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"youremail@gmail.com"});  
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Email Subject");
sendIntent.putExtra(Intent.EXTRA_STREAM,tvFechaSi.getText());
sendIntent.setType("text/html");
startActivity(sendIntent);

答案 1 :(得分:0)

您可以使用ACTION_SEND意图操作:

Intent i = new Intent(Intent.ACTION_SEND);  
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"wrfrewf@gmail.com"});  
i.putExtra(Intent.EXTRA_SUBJECT,"subject goes here");  
i.putExtra(Intent.EXTRA_TEXT, tvFechaSi.getText());  
startActivity(Intent.createChooser(i, "Select email application."));