Android calls the system's mail Method

Source: Internet
Author: User

// The action of the system email system is Android. content. Intent. action_send.
Intent email = new intent (Android. content. Intent. action_send );
Email. settype ("plain/text ");
Emailreciver = new string [] {"zhouyongyang122@gmail.com", "421134693@qq.com "};
Emailsubject = "you have a text message ";
Emailbody = sb. tostring ();

// Set the default email address
Email. putextra (Android. content. Intent. extra_email, emailreciver );
// Set the default email title
Email. putextra (Android. content. Intent. extra_subject, emailsubject );
// Set the content to be sent by default
Email. putextra (Android. content. Intent. extra_text, emailbody );
// Call the system's email system
Startactivity (intent. createchooser (email, "select email sending software "));

 

With attachment:

Intent returnit = new intent (intent. action_send );

String [] TOS = {"wangmeng@gmail.com"}; // send to someone

String [] CCS = {"tongyue@gmail.com"}; // carbon copy to someone

Returnit. putextra (intent. extra_email, TOS );

Returnit. putextra (intent. extra_cc, CCS );

Returnit. putextra (intent. extra_text, "body ");

Returnit. putextra (intent. extra_subject, "subject ");

Uri uri = URI. parse ("file: // sdcard/mysong.mp3 ");

Returnit. putextra (intent. extra_stream, Uri );

Returnit. settype ("audio/MP3"); // use this format no matter what your attachment type is

Returnit. settype ("message/rfc882 ");

Intent. createchooser (returnit, "Choose email client ");

Startactivity (returnit );

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.