Send SMS page in Andorid and send mail

Source: Internet
Author: User

Jump to send SMS page

Uri Smstouri = Uri.parse ("smsto://10086"); Intent mintent = new Intent (Android.content.Intent.ACTION_SENDTO, Smstouri); StartActivity (mintent);

As we all know, calling other programs in Android is almost always used intent, so email is no exception.

In Android, there are three types of intent called email:
Intent.action_sendto Send without attachments
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, there may be other applications to implement the relevant functions, so in the execution of the time, the selection box will appear to choose.

1. Send Using Sentto
[Java]

Copy CodeThe code is as follows: Intent data=new Intent (intent.action_sendto);  Data.setdata (Uri.parse ("Mailto:[email protected]");  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:[email protected]");  Data.putextra (Intent.extra_subject, "This is the title");  Data.putextra (Intent.extra_text, "This is the content"); StartActivity (data);


Set the relevant parameters for the message by Putextra to intent.

2. Sending using Send
[Java]

Copy CodeThe code is as follows: Intent Intent = new Intent (intent.action_send);  String[] tos = {"[Email protected]"};  String[] CCS = {"[Email protected]"};  String[] BCCs = {"[Email protected]"};  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 = {"[Email protected]"};  String[] CCS = {"[Email protected]"};  String[] BCCs = {"[Email protected]"};  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, sent in the mail, there are recipients, CC, the secret sender. That is, separate through
Intent.extra_email,
INTENT.EXTRA_CC,
Intent.extra_bcc
For Putextra to be set, and a single attachment is sent, use Intent.extra_stream to set the address URI of the attachment.

3. Use Send_multiple to send multiple attachments
[Java]

Copy CodeThe code is as follows: Intent Intent = new Intent (intent.action_send_multiple);  String[] tos = {"[Email protected]"};  String[] CCS = {"[Email protected]"};  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 = {"[Email protected]"};  String[] CCS = {"[Email protected]"};  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, most of the time, by Putparcelablearraylistextra the URI address list of multiple attachments in the OK. In fact, it is very simple.

Send SMS page in Andorid and send mail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.