We all know that calling other programs in Android is almost always intent, so email is no exception.
In Android, there are three types of intent that call 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, just say that email can receive intent and do these things, may also have other applications to implement the relevant functions, so in the execution, the selection box will appear to select.
1. Use Sentto to send
[Java]
Copy Code code as follows:
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);
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);
Set the parameters for the message by Putextra to the intent.
2. Send by using send
[Java]
Copy Code code as follows:
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 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);
Very simple, send the message, there are recipients, CC, the secret sender. namely, by
Intent.extra_email,
INTENT.EXTRA_CC,
Intent.extra_bcc
For Putextra, and the sending of a single attachment, use Intent.extra_stream to set the address URI of the attachment.
3. Use Send_multiple to send multiple attachments
[Java]
Copy Code code as follows:
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);
Send multiple attachments, the most important time, through the Putparcelablearraylistextra of multiple attachments to the URI address list set into the OK. In fact, it is very simple.