We all know that calling otherProgramAlmost all intent is used for related processing. Therefore, email is no exception.
In Android, there are three types of intent for calling Email:
Intent. action_sendto send without attachment
Intent. action_send send with attachment
Intent. action_send_multiple send with multiple attachments
Of course, the so-called call email only means that the email can receive intent and do these things. Other applications may also implement related functions. Therefore, during execution, the Select box is displayed.
1. Use sentto to send
[Java]
intent DATA = new intent (intent. action_sendto);
data. setdata (URI. parse ("mailto: way.ping.li@gmail.com");
data. putextra (intent. extra_subject, "this is the title");
data. putextra (intent. extra_text, "this is the content");
startactivity (data);
Intent DATA = new intent (intent. action_sendto );
Data. setdata (URI. parse ("mailto: way.ping.li@gmail.com "));
Data. putextra (intent. extra_subject, "this is the title ");
Data. putextra (intent. extra_text, "this is content ");
Startactivity (data );
You can set the mail parameters to putextra in intent.
2. Send with send
[Java]
Intent intent = new intent (intent. action_send );
String [] TOS = {"way.ping.li@gmail.com "};
String [] CCS = {"way.ping.li@gmail.com "};
String [] BCCs = {"way.ping.li@gmail.com "};
Intent. putextra (intent. extra_email, TOS );
Intent. putextra (intent. extra_cc, CCS );
Intent. putextra (intent. extra_bcc, BCCs );
Intent. putextra (intent. extra_text, "body ");
Intent. putextra (intent. extra_subject, "subject ");
Intent. putextra (intent. extra_stream, Uri. parse ("file: // MNT/sdcard/a.jpg "));
Intent. settype ("image /*");
Intent. settype ("message/rfc882 ");
Intent. createchooser (intent, "Choose email client ");
Startactivity (intent );
intent = new intent (intent. action_send);
string [] TOS = {"way.ping.li@gmail.com"};
string [] CCS = {"way.ping.li@gmail.com "};
string [] BCCs = {"way.ping.li@gmail.com"};
intent. putextra (intent. extra_email, TOS);
intent. putextra (intent. extra_cc, CCS);
intent. putextra (intent. extra_bcc, BCCs);
intent. putextra (intent. extra_text, "body");
intent. putextra (intent. extra_subject, "subject");
Intent. putextra (intent. extra_stream, Uri. parse ("file: // MNT/sdcard/a.jpg "));
Intent. settype ("image /*");
Intent. settype ("message/rfc882 ");
Intent. createchooser (intent, "Choose email client ");
Startactivity (intent );
It is very simple. There are recipients, CC users, and BCC in the mail. That is, pass
Intent. extra_email,
Intent. extra_cc,
Intent. extra_bcc
To set putextra, and send a single attachment, use intent. extra_stream to set the url uri of the attachment.
3. Use send_multiple to send multiple attachments
[Java]
Intent intent = new intent (intent. action_send_multiple );
String [] TOS = {"way.ping.li@gmail.com "};
String [] CCS = {"way.ping.li@gmail.com "};
Intent. putextra (intent. extra_email, TOS );
Intent. putextra (intent. extra_cc, CCS );
Intent. putextra (intent. extra_text, "body ");
Intent. putextra (intent. extra_subject, "subject ");
Arraylist <URI> imageuris = new arraylist <URI> ();
Imageuris. Add (URI. parse ("file: // MNT/sdcard/a.jpg "));
Imageuris. Add (URI. parse ("file: // MNT/sdcard/B .jpg "));
Intent. putparcelablearraylistextra (intent. extra_stream, imageuris );
Intent. settype ("image /*");
Intent. settype ("message/rfc882 ");
Intent. createchooser (intent, "Choose email client ");
Startactivity (intent );
Intent intent = new intent (intent. action_send_multiple );
String [] TOS = {"way.ping.li@gmail.com "};
String [] CCS = {"way.ping.li@gmail.com "};
Intent. putextra (intent. extra_email, TOS );
Intent. putextra (intent. extra_cc, CCS );
Intent. putextra (intent. extra_text, "body ");
Intent. putextra (intent. extra_subject, "subject ");
Arraylist <URI> imageuris = new arraylist <URI> ();
Imageuris. Add (URI. parse ("file: // MNT/sdcard/a.jpg "));
Imageuris. Add (URI. parse ("file: // MNT/sdcard/B .jpg "));
Intent. putparcelablearraylistextra (intent. extra_stream, imageuris );
Intent. settype ("image /*");
Intent. settype ("message/rfc882 ");
Intent. createchooser (intent, "Choose email client ");
Startactivity (intent );
When sending multiple attachments, you can use putparcelablearraylistextra to set the URI list of multiple attachments. In fact, it is quite simple.